Skip to content
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

fix(Fabric): not working animations on second-top screen #2270

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented Jul 30, 2024

Description

PR fixing animations on Fabric.

The problem started in RN 0.74, from which suspending the component triggers its useLayoutEffect. It has the consequences in Animated since detaching the native node happens then: https://github.com/facebook/react-native/blob/a5b84b925891fa509bec2e5ee5988bcb0326e198/packages/react-native/Libraries/Animated/useAnimatedProps.js#L221-L238.

Changes

Test code and steps to reproduce

Check Test887.tsx to see that on fabric, when going forward or back, without this change the screen below is not animating.

@kkafar kkafar changed the title fix: restore animation on fabric fix(Fabric): not working animations on second-top screen Jul 30, 2024
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have better option right now. We must do some research on why exactly this is different between Fabric & Paper and most likely try to patch this in core.

Comment on lines +28 to +30
const freezePreviousScreen = isFabric()
? size - index > 2
: size - index > 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep in mind that this is only a heuristics anyway and animations won't work on third-top screen etc.

For now we can proceed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only see this as a problem when we have multiple transparent modals, in which case I wouldn't enable freeze on that navigator anyway.

Comment on lines +10 to +12
function isFabric() {
return 'nativeFabricUIManager' in global;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this should be reliably available during the very first render, so we're safe on that front (the value won't differ on first & consecutive renders).

@WoLewicki WoLewicki merged commit 725929a into main Jul 31, 2024
3 checks passed
@WoLewicki WoLewicki deleted the @wolewicki/add-js-fabric-check branch July 31, 2024 08:39
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…nsion#2270)

PR fixing animations on Fabric.

The problem started in RN 0.74, from which suspending the component triggers its useLayoutEffect. It has the consequences in Animated since detaching the native node happens then: facebook/react-native@a5b84b9/packages/react-native/Libraries/Animated/useAnimatedProps.js#L221-L238.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants