Open jbcullis opened 2 years ago
Many of our core contributors are taking some much needed vacation throughout December 2021. Thank you for being patient while we relax, recharge, and return to a normal responsiveness in January 2022. In the meantime feel free to continue to pose questions, open issues, and make feature requests - you just may not get a response right away.
Animated.timing(this.state.ViewOffset, {duration: 200, toValue: 0, useNativeDriver: true}).start();
ViewOffset is not one of the XAML composition animation options that can be triggered by useNativeDriver
, so it doesn't know how to animate this. That's a gap between RN animations and XAML animations to date, not yet implemented.
As a workaround you should be able to use native animations for Translate. Does that work for you?
See related discussion in similar issues like this one: #9249.
@chrisglein in the example above, ViewOffset is the prop where I'm storing the AnimatedTiming value, the transform is using translateX like so: transform: [{translateX: this.state.ViewOffset}]
Just to clarify - the animation works correctly if you don't fetch data / do some async operation? Have you tried this on other platforms (iOS / Android)?
@rozele Yes, works on ios, macos, and android.
On further testing, it seems to matter how much data is returned. I just checked a UI that returns a single row before running the animation and it did run, but not smooth. I have other screens that have a couple of calls to get single rows for the UI setup and those do not load. Could it be a timing issue?
I also tested using await vs .then and both yield the same result.
Problem Description
If you have a function that fetches data using async/await, and then run an Animated.timing at the end of that function, the animation will not run. Changing useNativeDriver to false sees the animation run correctly, otherwise changing the Animated.timing to include a force update (.start(() => this.forceUpdate())) will show the UI abruptly, but not animate.
Steps To Reproduce
Add an offset to the state
this.setState({ViewOffset: new Animated.Value(300)});
Function to get data and run animation - will slide ui in from right
UI
Expected Results
Animation should run.
CLI version
npx react-native --version
Environment
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
No response
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
No response