react-native-slider icon indicating copy to clipboard operation
react-native-slider copied to clipboard

Wrong order of events when changing maximumValue and the value prop

Open jlo1 opened this issue 6 years ago • 2 comments

When both maximumValue and value prop are adjusted, the thumb's position is set to value on the old min/max slider track, then the slider's track adjusts to the new maximumValue. But order of events should occur the other way around.

e.g. scenario: slider's initial props are set to {:minimumValue 0 :maximumValue 100 :value 50} update slider component props to {:value 100 :maximumValue 200} current result: slider component draws the thumb at the end of the slider even though the max value is 200; and interacting with the slider will readjust slider's value to new min/max value (e.g. dragging left slightly will recalibrate the thumb's current position to be near the 200 mark)

jlo1 avatar Apr 25 '18 01:04 jlo1

a workaround is to set new min/max first and slider values afterwards:

this.setState({ sliderMax: NEW_MAX }, () => { this.setState({ sliderValue: VALUE }) })

this is not ideal but fixes the wrong behavior of the slider

FelixMaulwurf avatar Jun 25 '18 14:06 FelixMaulwurf

@FelixMaulwurf You save my day, it did work

phthhieu avatar Jan 02 '19 04:01 phthhieu