react-native-slider
react-native-slider copied to clipboard
Wrong order of events when changing maximumValue and the value prop
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)
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 You save my day, it did work