jobtoday / react-native-image-viewing

Tiny, purely TS, modal component for viewing images 🏙
https://exp.host/@antonkalinin/react-native-image-viewing
MIT License
880 stars 287 forks source link

Incorrect usage of Animated.Value causing gestures and state to be reset #202

Open gaearon opened 12 months ago

gaearon commented 12 months ago

It is not correct to re-create Animated.Value on every render like this:

This is not valid because Animated values are stateful, and so they should be kept in state or a ref. Otherwise, any state update to the component will interrupt the current animation and/or gesture.

I'm filing this for future readers or whoever has a fork of this code in their codebase.

A potential fix would look like this: https://github.com/bluesky-social/social-app/pull/1618