sacmii / rn-vertical-slider

React Native Vertical Slider
MIT License
201 stars 45 forks source link

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

Open ryancat opened 1 year ago

ryancat commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.