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

When slider got re-rendered with a new onChange prop, it won't be triggered #87

Open
ryancat opened this issue Jun 20, 2023 · 2 comments

Comments

@ryancat
Copy link
Contributor

ryancat commented Jun 20, 2023

I noticed that if the component got re-rendered with a new onChange/onComplete prop, it won't be used. This is due to how the panResponder is created in https://github.com/sacmii/rn-vertical-slider/blob/master/src/index.tsx#L168, which is a Ref that never updates.

@ryancat
Copy link
Contributor Author

ryancat commented Jun 20, 2023

This is likely an issue in how PanResponder works with useRef. See https://snack.expo.dev/@chxryan/panresponder-caching-issue

I got inspired from https://stackoverflow.com/questions/58939572/how-to-use-panresponder-in-functional-components and tried useMemo, and it worked.

ryancat added a commit to ryancat/rn-vertical-slider that referenced this issue Jun 20, 2023
@ryancat
Copy link
Contributor Author

ryancat commented Jun 20, 2023

I tried in my PR above but that is causing the slider value got reset on each re-render. I'll look into this when I have more time.

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

1 participant