-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layout Animation breaks after navigate #4516
Comments
I can confirm, exactly the same thing happens for me on iOS. It also happens when using As a workaround I'm changing the key on wrapping container based on |
did the animation work for android? I can not animate anything with FlatList Android |
Yes, in my case everything works as expected in Android |
We are experiencing the same issue. Layout animation works fine but after navigating to another screen, the animation stop working. Here is a minimal reproduction repository
And the following capture from iOS simulator : Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-03.at.11.28.46.mp4 |
Hey Same here, there's enough reproductions above so i will skip that - layout breaks on stack navigation screen change and going back, however tried to re-render on focus hack but no that didn't work. |
To make the hack works you need to change the |
alias not in my case, forcing a render on the layout views based the focus prop does nothing in my components that have this issue. Enter/Exit animations seem to still work just the layout is naffed. Thanks |
Same issue here only on iOS: bf6d3afd-b08a-4715-a263-89de0f4c6c17.mp4 |
Same here. Changing key doesn't help |
FlatList is also affected. Related issue: #4450, the |
They are using the same thing under the hood. So it's expected I guess. |
Same issue @react-navigation/native-stack: 6.9.13 |
Is not solved yet:
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-28.at.10.54.08.mp4 |
Has anyone found a better workaround than changing the key? PS: I realize that @emzet93 seems to have managed to apply the workaround without the children's animations launching. Out of curiosity, how did you do it? |
Hello again! I'd like to help solve the problem, do you have any hints or tips when it comes to specific places in the code to look? By the way, in the discussion related to PR #4421, @piaskowyk said that someone would try to investigate the problem, has that been possible? Were there any conclusions as to what changes should be made to solve the problem? Thanks so much for your work, I hope I'm not spamming the notifications too much. |
While this issue is being resolved here, you can temporarily use the 'InteractionManager' from react-native to hack the problem:
|
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary Closes #4816 Closes #4516 Fixing issue with react navigation. If given view is inside some view controller and it has layout animation don't remove its animations from subtree <table> <tr><td>BEFORE</td><td>AFTER</td></tr> <tr><td> https://github.com/software-mansion/react-native-reanimated/assets/56199675/e1581853-f2ba-4b55-a07a-977ca4a84808 </td><td> https://github.com/software-mansion/react-native-reanimated/assets/56199675/c366c6ff-1dc7-4b70-b9ed-33582f49da4d </td></tr> </table> <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. --> ## Test plan Code: <details> ```js import {NavigationContainer, useNavigation} from '@react-navigation/native'; import {createNativeStackNavigator} from '@react-navigation/native-stack'; import React from 'react'; import {Pressable, Text, View} from 'react-native'; import Animated, {Layout} from 'react-native-reanimated'; const Stack = createNativeStackNavigator(); const Screen1 = () => { const [isOpen, setIsOpen] = React.useState(false); const navigation = useNavigation(); return ( <> <Animated.View style={{backgroundColor: 'red'}} layout={Layout.duration(1000)}> <Pressable onPress={() => setIsOpen(!isOpen)}> <Text>Open</Text> </Pressable> {isOpen && <View style={{width: 300, height: 400}} />} </Animated.View> <Text onPress={() => navigation.navigate('Screen2')}>nav</Text> </> ); }; const Screen2 = () => { const [isOpen, setIsOpen] = React.useState(false); const navigation = useNavigation(); return ( <> <Animated.View style={{backgroundColor: 'red'}} layout={Layout.duration(1000)}> <Pressable onPress={() => setIsOpen(!isOpen)}> <Text>Open</Text> </Pressable> {isOpen && <View style={{width: 300, height: 400}} />} </Animated.View> </> ); }; const App = (props: Props) => { return ( <NavigationContainer> <Stack.Navigator> <Stack.Screen name="Screen1" component={Screen1} /> <Stack.Screen name="Screen2" component={Screen2} /> </Stack.Navigator> </NavigationContainer> ); }; export default App; ``` </details> <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. --> --------- Co-authored-by: Aleksandra Cynk <aleksandra.cynk@swmansion.com> Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com>
Bravo for the fix! |
🙌🏼 🙌🏼 🙌🏼 Thanks @Latropos @piaskowyk for the #4997 |
I wish you could include this in 3.5.4. |
MVP! |
Seems still not working 🥲 The example of #4997 is implemented with the react-navigation-native-stack but with the react-navigation-stack it doesn't work |
@Latropos I've created a new repro here: https://github.com/nicolascavallin/reanimated-bug Basically, the existing keys lost their layout animation ability after the navigation with the Let me know how I can help. Thanks in advance. Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-10-11.at.17.53.02.mov |
Any update on this. with |
Hey @batuhansahan are you sure that with the I reopened the issue because I'm having trouble with the |
Hi, @nicolascavallin, I can confirm the issue still exist. With native-stack. When I'm navigating from material-top-tabs to native-stack, then back to top-tabs, all layout animations in top-tabs navigator are broken. "react-native": "0.72.6", Also there is freezeOnBlur: true option enabled. |
It was resolved for me. Using the following package versions "@react-navigation/native": "6.1.9",
"@react-navigation/native-stack": "6.9.17",
"react-native": "0.72.6",
"react-native-reanimated": "3.6.1",
"react-native-screens": "3.27.0", See my working example here: https://github.com/davidjbng/reanimated-layout-animation-bug Simulator.Screen.Recording.-.iPhone.15.-.2023-12-06.at.14.58.14.mp4 |
I am still having this issue,
The |
I think the reason that david was able to have his issue fixed, at least per the example he included, is that this only occurs when navigating from one stack to another. If you are navigating between screens within the same stack this issue indeed has been fixed in previous merges. I am using
and still seeing this issue when navigating between bottom tabs stack and another native stack at the same level as the bottom tabs stack. However, if i keep navigation between screens to within the same stack the issue is not a problem. |
The issue was fixed in #5495 |
What version can we expect this to be deployed with ? Thank you for fixing btw. Love the layout animations and was bummed this issue was making them less usable :) |
@sguidotti It will be available in the next release, but you can test it now via nightly |
I am still encountering this issue with tabs using the nightly build: reanimated: 3.9.0-nightly-20240403-6dc1e6fbf Initially the layout transition works correctly, then after navigating to another tab and then returning, the transitions no longer occur. |
For me on "react-native-reanimated": "^3.9.0-rc.0" navigating between different stacks works. The stack i am navigating to exists outside of the tab navigation stack. All are native stacks as well. |
Description
We are using
@react-navigation/stack
, and we are animating our UI search bar with the<Animation.View entering={FadeIn} exiting={FadeOut} .../>
and everything insides<Animation.View layout={Layout} .../>
The UI animation works right in Android and in iOS. But, only in iOS, after do a
navigate
, and then going back, seems like something is break and the Layout animation doesn't work.We tried with
detachPreviousScreen
to be sure that the screen is not unmounted but the bug still appears.274343957-b7472bc9-9297-4335-9d81-c996112f16fb.mov
Steps to reproduce
Snack or a link to a repository
https://github.com/nicolascavallin/reanimated-bug
Thanks to @dayze for the repro
Reanimated version
3.1.0
React Native version
0.71.8
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Release mode
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: