are you using the new architecture?
I'm guessing no.
which version of react & react-native are you using?
"expo": "~49.0.15",
"react": "18.2.0",
"react-native": "0.72.6",
"@react-native-community/slider": "4.4.2"
Description
onValueChange triggers an extra time after onSlidingCompleted on Android.
Inside of onSlidingCompleted I'm setting the slider value to a specific value when the thumb button is pressed if the current value and saved previous value is the same. This works but since onValueChange is triggered an additional time after onSlidingCompleted the slider jumps back to the initial pressed position.
This can be a bit hard to see in this project because it is so small/fast but you should be able to see it flash to the value 5. I think this works correctly on iOS.
Drag the slider to the right.
Press the thumb button a bunch of times.
Expected: after one press of the thumb button the slider should jump to the value 5.
Result: the slider jumps to 5 and back to the original position.
Expected order:
onSlidingStartonValueChange (if there is a value change at all)
onSlidingComplete
Actual order:
onSlidingStartonValueChange (if there is a value change at all)
onSlidingCompleteonValueChange
Reproducing this still: snack (though snacks on android & iOS are broken as mentioned in #587)
As a possible fix for some until the library's updated, something that helped me was abstracting away logic where possible from onValueChange to onSlidingStart
Environment
react-native info output:
are you using the new architecture? I'm guessing no.
which version of react & react-native are you using? "expo": "~49.0.15", "react": "18.2.0", "react-native": "0.72.6", "@react-native-community/slider": "4.4.2"
Description
onValueChange triggers an extra time after onSlidingCompleted on Android.
Inside of
onSlidingCompleted
I'm setting the slider value to a specific value when the thumb button is pressed if the current value and saved previous value is the same. This works but sinceonValueChange
is triggered an additional time afteronSlidingCompleted
the slider jumps back to the initial pressed position.This can be a bit hard to see in this project because it is so small/fast but you should be able to see it flash to the value
5
. I think this works correctly on iOS.Expected: after one press of the thumb button the slider should jump to the value 5. Result: the slider jumps to 5 and back to the original position.
Expected order:
onSlidingStart
onValueChange
(if there is a value change at all)onSlidingComplete
Actual order:
onSlidingStart
onValueChange
(if there is a value change at all)onSlidingComplete
onValueChange
Reproducible Demo
Repro: https://github.com/henrikvilhelmberglund/react-native-slider-issue-android
Code: