Can't get Layout Animations to work on a simple View
Description
Not sure if it's a bug in the library, or if I'm missing something in the setup, but I can't get Layout Animations to work in any way, none of the stages seem to be working (entering, exiting, layout). I have a simple view that I'm trying to animate when toggling a state variable, but it just appears without any animations at all.
Expected behavior
Expected the view to fade in and out when mounting/unmounting.
Actual behavior & steps to reproduce
No animations are working in either stage.
Snack or minimal code example
{showView && <Animated.View
style={[styles.ball, animatedStyles]}
entering={FadeIn.duration(2000).springify().mass(0.3)}
exiting={FadeOut.duration(2000).springify().mass(0.3)}
/>}
Package versions
- React Native: 0.66.0
- React Native Reanimated: 2.3.1 / https://github.com/software-mansion/react-native-reanimated#main (tried with both)
- NodeJS: 16.1.0
- Xcode: 13.2.1
Affected platforms
- [ ] Android
- [x] iOS
- [ ] Web
Issue validator
The issue is valid!
You seems using the useAnimatedStyle with component,
{showView && <Animated.View style={styles.ball} entering={FadeIn.duration(2000).springify().mass(0.3)} exiting={FadeOut.duration(2000).springify().mass(0.3)} />}
@Majiedo oh sorry, I forgot to mention that I tried it both ways actually, with and without the animated styles, and I still got the same outcome.
same, I've just setup the LayoutAnimation example, but the entering and exiting animation doesn't work.
+1 I have the same problem.
Hey @ernestasgobionis!
I encourage you to check out how it's done in the Example app
If it won't help, it would really help us if you provided Snack code example with your not-working code
Hi @kkafar,
I think I have checked the Example app before and everything was working fine there, and as far as I remember I basically copied one of the examples and it didn't work.
But now I tried to reproduce it, and it seems to work now (magic 😀). Unless I was doing something different when submitting this issue, but I think it was an even simpler case that I used to reproduce it now.
Sometimes it this way! :D Glad to hear its working for you. Closing.