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.

onValueChanges is called on programmatic value changes on Android

See original GitHub issue

Environment

System: OS: macOS 11.6 CPU: (16) x64 Intel® Core™ i9-9980HK CPU @ 2.40GHz Memory: 1.06 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.16.0 - /var/folders/21/5xmhgtlx4bj0gthrmm8tm3zc0000gq/T/yarn–1657226700390-0.0757475079991885/node Yarn: 1.22.11 - /var/folders/21/5xmhgtlx4bj0gthrmm8tm3zc0000gq/T/yarn–1657226700390-0.0757475079991885/yarn npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm Watchman: 2021.09.13.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/eueddemkim-new/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 30, 31 Build Tools: 30.0.2, 31.0.0 Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Description

The doc says, onValueChanges: Callback continuously called while the user is dragging the slider. It works as expected on iOS device and simulators, but on Android devices(tested with Pixel 3 XL, Android 11), onValueChanges is called on every value changes, even from setState.

I’m on latest 4.2.4 version. "@react-native-community/slider": "^4.2.4",

Reproducible Demo

const [state, setState] = useState(0);
const onValueChange = (value: number) => {
    console.log("onValueChange invoked", value);
};

.... (do state change after some time interval) ...

<Slider
    minimumValue={0}
    maximumValue={100}
    step={1}
    value={state}
    onValueChange={onValueChange}
 />

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
aryscommented, Oct 26, 2022

Are there any short term work-arounds? Otherwise I can’t use this for Android

I used onSlidingComplete instead, works fine.

0reactions
jamesisaaccommented, Dec 15, 2022

onSlidingComplete doesn’t seem to get called on Android when using accessibilty controls to adjust the slider, only onValueChange.

So unfortunately from what I can tell, having a slider that has some programmatic control (e.g. the seek bar on a playing video) isn’t currently compatible with using accessibility controls on the slider.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling onValueChange(NumberPicker) programmatically on ...
After valuePicker.setValue(2), I want to execute the code under onValueChange method (change the world) automatically. android · listener ...
Read more >
How to assign a value programmatically without triggering the ...
This method Enables/postpones edit value change notification events. For more information, please read the "TcxCustomEdit.LockChangeEvents" ...
Read more >
Element: <oj-select-single> - Oracle
When the value property changes due to programmatic intervention deferred validation is run, after all messages and messagesCustom property ...
Read more >
Triggering an onChange that requires event via ... - Reddit
a to the new value held within inputA , however I have to call the setA() method manually because the input value changes...
Read more >
DropDownList / How To / Detect whether the value change ...
You can check about whether value change happened by manual or programmatic by using change event argument that argument name is isInteracted ....
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