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 memoization for Animated components when no style is passed in #44269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RandomEngy
Copy link

Summary:
Any component wrapped via createAnimatedComponent() will always re-render, because it creates a new style object. It's impossible to memoize.

Adding useMemo() here ensures that the style object passed to the underlying object is stable: if no style is passed to the wrapped component, then memoization can work.

Allowing memoization to function when the style object is passed in will require a deeper fix. See https://fb.workplace.com/groups/rn.support/permalink/26084643474490921/

Before:
{F1496803038}

After:
{F1496805410}

Differential Revision: D56618868

Summary:
Any component wrapped via `createAnimatedComponent()` will always re-render, because it creates a new `style` object. It's impossible to memoize.

Adding `useMemo()` here ensures that the `style` object passed to the underlying object is stable: if no `style` is passed to the wrapped component, then memoization can work.

Allowing memoization to function when the `style` object is passed in will require a deeper fix. See https://fb.workplace.com/groups/rn.support/permalink/26084643474490921/

Before:
{F1496803038}

After:
{F1496805410}

Differential Revision: D56618868
@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 Apr 26, 2024
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. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants