Last active
November 14, 2022 20:55
-
-
Save vzts/253a69ac957b9daa4877d60f56f9491b to your computer and use it in GitHub Desktop.
How to convert native AnimatedInterpolation into js AnimatedInterpolation in React Native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Component = ({ interpolationNative }) => { | |
const interpolationJs = useRef(new Animated.Value(0)).current | |
useEffect(() => { | |
const listener = interpolationNative.addListener( | |
Animated.event([{ value: interpolationJs }], { useNativeDriver: false }), | |
) | |
return () => interpolationNative.removeListener(listener) | |
}, [interpolationNative, interpolationJs]) | |
// interpolate with interpolationJs | |
return ... // use animated value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment