react-component / react-component/slider

how to update value in slider when i change values ​​in input?

Open
#848 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.1k
Forks
768
Avg merge
11d 22h
Merged PRs (30d)
5

Description

image

gif issue:
anim

component:
` const MyComponent = () => {
const [value, setValue] = useState(1000000)

const min = 0
const max = 5000000

const handleChange = (e) => {
    let val = Math.max(min, Math.min(max, Number(e.target.value)))
    setValue(val)
}

return (
<>

          <input
            type="number"
            value={value}
            onChange={handleChange}
            onKeyUp={(e) => {
              let str = e.target.value
              str = str.replace(/\b0+/g, '')
              setValue(str)
            }}
          />
      
          <Slider
            min={min}
            max={max}
            step={10000}
            className={s.slider}
            onChange={(val) => setValue(val)}
            defaultValue={1000000}
          />
        </div>
      </>

)
} `

I do not understand how to update the slider slider when the input changes, help pls

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied MyComponent example and the Slider component entry point, focusing on how the input value and slider value are connected. Confirm the intended value flow and define done as having the slider reflect valid input changes while preserving slider updates; no repository file or test is identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.