Skip to content

Animated: Switch to useInsertionEffect#46474

Closed
yungsters wants to merge 1 commit into
facebook:mainfrom
yungsters:export-D62602336
Closed

Animated: Switch to useInsertionEffect#46474
yungsters wants to merge 1 commit into
facebook:mainfrom
yungsters:export-D62602336

Conversation

@yungsters
Copy link
Copy Markdown
Contributor

Summary:
Changes useAnimatedPropsLifecycle_passiveEffects (the experimental lifecycle management in useAnimatedProps) to useInsertionEffect instead of useEffect.

The primary motivation for this change is avoiding detaching and attaching of animations when an enclosing Activity's mode changed from visible to hidden and back to visible.

Changelog:
[Internal]

Differential Revision: D62602336

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Sep 12, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62602336

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62602336

Summary:
Pull Request resolved: facebook#46474

Changes `useAnimatedPropsLifecycle_passiveEffects` (the experimental lifecycle management in `useAnimatedProps`) to `useInsertionEffect` instead of `useEffect`. This has a few benefits:

1. Prevents any Activity detach and attach events from triggering Animated lifecycle work (which adds to effect mounting and unmounting time).
2. Fixes batching of native Animated operations across components. (Since we flush the operation queue in a passive effect, enqueueing operations in a passive effect causes weird interleaving of enqueuing and flushing.)
3. Enables animations to be started in layout effects.

Changelog:
[Internal]

Differential Revision: D62602336
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62602336

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 1c7fd8b.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 13, 2024
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @yungsters in 1c7fd8b

When will my fix make it into a release? | How to file a pick request?

@yungsters yungsters deleted the export-D62602336 branch March 13, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants