Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChange not working in browser #9

Open
dracoblackie opened this issue Jun 23, 2021 · 6 comments
Open

onChange not working in browser #9

dracoblackie opened this issue Jun 23, 2021 · 6 comments

Comments

@dracoblackie
Copy link

I have tested some code in android, and it worked fine. Then when run in chrome it seems like we dont hit onChange.

Neither with a static value
<WheelPicker
selectedIndex={defaultIndex}
options={someOptionsArray}
onChange={(index) => this.setState({someStateValue: 2})}
/>
or if we set someStateValue to someOptionsArray[index]

In chrome devtools, i have set a debugpoint at onChange. When i run it on an android emulator we hit it in the debugger, but when run on a webserver, we dont hit the onChange.
Additionally i have tried with a simple console.log("hello world") instead =>
<WheelPicker
selectedIndex={defaultIndex}
options={someOptionsArray}
onChange={(index) => {
console.log("Hello World")
}
}
/>
We do not seem to get the message in the console of the browser.

In both tests i have used mouse and keyboard.

I will isolate the code into a modal module to see if this fixes things, but thought this would be helpfull.

@erksch
Copy link
Owner

erksch commented Jun 23, 2021

Do you mean with react-native-web? I have never used it but I'll try to reproduce.

@dracoblackie
Copy link
Author

dracoblackie commented Jun 24, 2021

Yes, i mean with react-native-web. After writing the bug-report i realized that it never states in this library that it supports web, so this might be more of a feature request.
Also, isolating the code did not change the outcome.

@erksch
Copy link
Owner

erksch commented Aug 12, 2021

Sorry, I currently do not come around to reproduce your example, if you want you can create a pull request for react-native-web support, feel free to do so.

react-native-wheely uses a FlatList internally and calls onChange on onMomentumScrollEnd. Maybe onMomentumScrollEnd is not called in web.

@ToshKoevoets
Copy link

ToshKoevoets commented Sep 25, 2021

@erksch indeed looks like onMomentScrollEnd isn't fired on web:

    onScroll={Animated.event(
      [{ nativeEvent: { contentOffset: { y: scrollY } } }],
      { useNativeDriver: true, listener: (event) => handleScroll(event)  },
    )}

Solution might be to call it on scroll all the time although there might be some performance issues there.

@alexkendall
Copy link

I've added react-native for web support off this forked repoistory: https://github.com/alexkendall/react-native-wheely

@Jaza
Copy link

Jaza commented Aug 27, 2024

FYI @alexkendall has a fix for this pending review at #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants