Skip to content

Instantly share code, notes, and snippets.

@vzts
Last active November 14, 2022 20:55
Show Gist options
  • Save vzts/253a69ac957b9daa4877d60f56f9491b to your computer and use it in GitHub Desktop.
Save vzts/253a69ac957b9daa4877d60f56f9491b to your computer and use it in GitHub Desktop.
How to convert native AnimatedInterpolation into js AnimatedInterpolation in React Native
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