zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
883 stars 231 forks source link

How to limit slider? #190

Closed istoros closed 3 years ago

istoros commented 3 years ago

I want to limit my slider between 25 and 75 values on 0-100 line On onChange callback I set new state, state is update, but slider value not changes (slider value not connected with my state value) What solution of this problem?

Slider component: `export default ({value, onChange}: any) => { return (

) }` My component: `const [value, setValue] = useState(10); { setValue(Math.min(Math.max(val as number, 25), 75)); }} />`
stonebk commented 3 years ago

Can you not just use the min and max props?

istoros commented 3 years ago

@stonebk I can't. I must to have 0-100 range, limited 25-75 values. I view source code react-slider, it use personal state. My solution is use forceUpdate. Is there another ways?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.