question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Animated.event with useNativeDriver disregards interpolations/etc when re-rendering

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
janicduplessiscommented, Mar 28, 2017

Thanks for trying that out, I’ll see if I can figure out the cause with @scarlac repro.

1reaction
willdawsonmecommented, Apr 3, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found