onSlidingComplete is not working on Android
Environment
System: OS: macOS 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz Memory: 22.35 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: 1.19.0 - /usr/local/bin/yarn npm: 6.11.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.1 IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1
react-native-slider version 2.0.2
Description
The same code works as expected on iOS ('on sliding complete' is logged in console) but not on android Although currentValue is correctly changed on Android as well as on iOS
Reproducible Demo
const [currentValue, setCurrentValue] = useState();
<Slider
style={{ width: screenWidth - 48, height: 40 }}
minimumTrackTintColor={theme.colors.pinkButton}
maximumTrackTintColor={theme.colors.grayIcon}
value={currentValue}
onValueChange={setCurrentValue}
onSlidingComplete={value => {
console.log('on sliding complete')
}}
/>
Please try version 2.0.7 it seems to work correctly on example app. I'm closing this issue, if it still occurs on the latest version, please let me know, I'll reopen that issue :)
This is still occurring for me on Android with version 2.0.7
Same for me, any workarounds to make it works?
This is still occurring for me on Android with version 2.0.9
using version 2.0.9 and still occurring
This issue is still occurring on Android, and on iOS emulator the onSliderComplete function is not always called as well. Why isn't this issue in opened state?
onSlidingComplete is not working even with version 3.0.3 on Android. Please open this issue and kindly fix it.
To run onSlidingComlete in android please do the following changes in << ReactSliderManager.java >> as given below :-
1. Comment this line -->>
ReactSlidingCompleteEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingComplete"), in the getExportedCustomDirectEventTypeConstants() method like given below
@Override
public Map getExportedCustomDirectEventTypeConstants() {
return MapBuilder.of(
// ======= Comment below line============
// ReactSlidingCompleteEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingComplete"),
ReactSlidingStartEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingStart"));
}
2. Add the given below method
@Override
public Map getExportedCustomBubblingEventTypeConstants() {
return MapBuilder.builder()
.put(
ReactSlidingCompleteEvent.EVENT_NAME ,
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onRNCSliderSlidingComplete")))
.build();
}
Now when event is fired from native code is work properly @michalchudziak