Animated.event with useNativeDriver disregards interpolations/etc when re-rendering
See original GitHub issueThe initial interpolated animation value of an Animated.event
with useNativeDriver
is calculated correctly, but once it gets re-rendered then the interpolation is ignored. But when it re-renders again, then the interpolated value is again correct. So:
1st render: Correct value
2nd render: Incorrect (0)
3rd render: Correct.
4th…*: Correct.
This also applies to Animated.add
nodes as well.
I simulate re-rendering with a timer that calls this.forceUpdate()
.
Here is a boiled-down code sample.
Here is a video of the code sample running (RNPlay won’t work for this)
I don’t know how to work around this. Using setValue
in componentWillMount
doesn’t make a difference.
Additional Information
- React Native version: 0.41.2
- Platform: iOS
- Operating System: macOS 10.12.3
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Animated: `useNativeDriver` was not specified issue of ...
When working with Animated.event() , add useNativeDriver: false/true to the animation config. <Animated.ScrollView scrollEventThrottle={1} ...
Read more >Using Native Driver for Animated
event . Here's a breakdown of the steps for an animation and where it happens: JS: The animation driver uses requestAnimationFrame to execute...
Read more >Animated.event - React Native Animated for Beginners
We are ignoring the raw event, which is the first argument, thus we pass null. The second argument is the gestureState which provides...
Read more >Using Native and Non-native Animations Together
We defined nativeAnim and jsAnim , which are Animated.Value . This value is driven by a native Animated.event triggered by a ScrollView's offset ......
Read more >Non-Native and Native Animated Values in React Native
event([{value: this.nonNativeScroll}], {useNativeDriver: false}));. How does this work? Calling Animated.event can actually return ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for trying that out, I’ll see if I can figure out the cause with @scarlac repro.
No luck here, but here’s a repro! https://snack.expo.io/SyQd4Bkal It doesn’t actually need interpolated values, just an Animated.Value.
In the repro, the ScrollView starts at an arbitrary x offset. After 3 seconds, the Header is re-rendered with a state update, which causes it to ignore the animated translateX value on the header until you re-scroll the main view.
Let me know if you need any more info! Thanks