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

Save theme memoization in a local WeakMap #237

Merged
merged 1 commit into from
Mar 2, 2023
Merged

Conversation

fortmarek
Copy link
Contributor

@fortmarek fortmarek commented Mar 2, 2023

Description

When upgrading to react-native-reanimated to 3.0.0, the app was crashing immediately upon opening with the following error:

Restyle crash screenshot

Turns out, react-native-reanimated freezes objects that are transformed to shareable – recursively. This means that theme was frozen and subsequently also the memoziation map we save to the theme was, too.

Instead of saving the memoziation directly inside the theme object, we can create a new WeakMap where the key is the theme itself and the value is the memoization map.

Reviewers’ hat-rack 🎩

  • Try out app with react-native-reanimated 3.0.0 -> it should not crash

Checklist

Copy link
Contributor

@mattfrances mattfrances left a comment

Choose a reason for hiding this comment

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

Code and tophat looks good!

@fortmarek fortmarek merged commit 1741b00 into master Mar 2, 2023
@fortmarek fortmarek deleted the fix/frozen-value branch March 2, 2023 14:09
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