Skip to content

Layout Animation breaks after navigate #4516

Closed

Description

@nicolascavallin

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

  1. Create a Layout Animation in Screen 1
  2. Navigate to Screen 2
  3. Go back to Screen 1.

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

Activity

  1. emzet93 commented on Jun 1, 2023

    @emzet93

    I can confirm, exactly the same thing happens for me on iOS. It also happens when using native-stack. However, it works ok if screen looses focus because of tab navigation change.

    As a workaround I'm changing the key on wrapping container based on isFocused variable, to trigger remounting all animated components inside. It works, but it requires bunch of hacks to prevent layout animations run on those
    elements because of this key change.

  2. fukemy commented on Jun 5, 2023

    @fukemy

    did the animation work for android? I can not animate anything with FlatList Android

  3. nicolascavallin commented on Jun 6, 2023

    @nicolascavallin
    Author

    did the animation work for android? I can not animate anything with FlatList Android

    Yes, in my case everything works as expected in Android

  4. dayze commented on Jul 3, 2023

    @dayze

    We are experiencing the same issue. Layout animation works fine but after navigating to another screen, the animation stop working.
    The issue is only encountered on iOS, debug/release build, simulator and real device.

    Here is a minimal reproduction repository

    "react-native": "0.72.1",
    "react-native-reanimated": "^3.3.0",
    "react-native-screens": "^3.22.0",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13"
    

    And the following capture from iOS simulator :

    Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-03.at.11.28.46.mp4
  5. added
    Repro providedA reproduction with a snippet of code, snack or repo is provided
    Missing reproThis issue need minimum repro scenario
    and removed
    Missing reproThis issue need minimum repro scenario
    Repro providedA reproduction with a snippet of code, snack or repo is provided
    on Jul 3, 2023
  6. s-t-sa commented on Jul 4, 2023

    @s-t-sa

    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.

  7. added
    Repro providedA reproduction with a snippet of code, snack or repo is provided
    and removed
    Missing reproThis issue need minimum repro scenario
    on Jul 5, 2023
  8. dayze commented on Jul 5, 2023

    @dayze

    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 key props on the Animated.View component

  9. 18 remaining items

  10. added and removed
    Needs reviewIssue is ready to be reviewed by a maintainer
    on Oct 11, 2023
  11. nicolascavallin commented on Oct 11, 2023

    @nicolascavallin
    Author

    @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 @react-navigation/stack. Not the new ones.

    Let me know how I can help.

    Thanks in advance.

    Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-10-11.at.17.53.02.mov
  12. batuhansahan commented on Nov 30, 2023

    @batuhansahan

    Any update on this. with react-native-reanimated = 3.6.0 still experiencing with the native stack.

  13. nicolascavallin commented on Dec 1, 2023

    @nicolascavallin
    Author

    Hey @batuhansahan are you sure that with the native-stack? Because it was solved here #4997.

    I reopened the issue because I'm having trouble with the stack by react-navigation (not the native one)

  14. AndrewTkachuk42 commented on Dec 5, 2023

    @AndrewTkachuk42

    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",
    "@react-navigation/material-top-tabs": "^6.6.5",
    "@react-navigation/native-stack": "^6.9.17",
    "react-native-reanimated": "^3.6.1",

    Also there is freezeOnBlur: true option enabled.
    It's iOS only. Android works fine.
    Hope this will help.

  15. davidjbng commented on Dec 6, 2023

    @davidjbng

    It was resolved for me.
    I originally created a reproduction to show the issue still exists, but it seems to be fixed now. I was also only having the issues on iOS.

    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
  16. Karthik-B-06 commented on Jan 30, 2024

    @Karthik-B-06

    I am still having this issue,

        "@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",
    

    The LinearTransition animation breaks after navigation.

  17. sguidotti commented on Feb 10, 2024

    @sguidotti

    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

       "react-native-reanimated": "^3.7.0",
       "@react-navigation/bottom-tabs": "^6.5.7",
       "@react-navigation/native": "^6.1.6",
       "@react-navigation/native-stack": "^6.9.17",
    

    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.

  18. bartlomiejbloniarz commented on Mar 25, 2024

    @bartlomiejbloniarz
    Member

    The issue was fixed in #5495

  19. sguidotti commented on Mar 25, 2024

    @sguidotti

    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 :)

  20. bartlomiejbloniarz commented on Mar 26, 2024

    @bartlomiejbloniarz
    Member

    @sguidotti It will be available in the next release, but you can test it now via nightly

  21. iamjoshua commented on Apr 4, 2024

    @iamjoshua

    I am still encountering this issue with tabs using the nightly build:

    reanimated: 3.9.0-nightly-20240403-6dc1e6fbf
    expo: 50.0.14

    Initially the layout transition works correctly, then after navigating to another tab and then returning, the transitions no longer occur.

  22. sguidotti commented on Apr 5, 2024

    @sguidotti

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: iOSThis issue is specific to iOSRepro providedA reproduction with a snippet of code, snack or repo is provided

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions