question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onSlidingComplete is not working on Android

See original GitHub issue

Environment

System: OS: macOS 10.14.6 CPU: (8) x64 Intel® Core™ 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')
        }}
      />

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

3reactions
LRNZ09commented, Dec 2, 2019

Same for me, any workarounds to make it works?

2reactions
veeru03commented, Oct 19, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

onSlidingComplete is not working on Android #118 - GitHub
onSlidingComplete is not working even with version 3.0.3 on Android. Please open this issue and kindly fix it. All reactions.
Read more >
React Native Android Slider cannot slide vertically on device
For some reason, Android just does not cope well when it is rotated vertically. componentWillMount () { this._panResponder = PanResponder.create ...
Read more >
@react-native-community/slider - npm
React Native component used to select a single value from a range of values.. Latest version: 4.4.0, last published: 9 days ago.
Read more >
Slider - React Native Archive
A component used to select a single value from a range of values.
Read more >
Calling 2 props onSLidingComplete in slider-React Native
Coding example for the question Calling 2 props onSLidingComplete in slider-React ... Why access the props of calling element is not working in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found