Skip to content

Use abort controller to prevent async setState after unmount. #463

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

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

nima-ap
Copy link
Contributor

@nima-ap nima-ap commented Sep 29, 2022

Describe the change

Only calls setState if not unmounted. useModuleInitializer was trying to set state in an async fashion, and this must always be accompanied by some cancellation or aborting mechanism in React, otherwise it is possible for a state update to happen on an unmounted component, causing memory leaks and warnings.

Screenshots

N/A

Documentation

N/A

Testing

I need help testing on [Android|iOS|Windows]

@github-actions
Copy link

Here are the build results
Assembled
Assembled-iOSAndroid0.65
Assembled-iOSAndroid0.69
Assembled-Windows0.65
Assembled-Windows0.69
Artifacts will only be retained for 90 days.

@ryantrem
Copy link
Member

I think technically in this case it is safe to ignore the warning (which as been removed in newer versions of React Native!), but the warning is also noisy and distracting so avoiding it still seems like a good idea to me.

@ryantrem ryantrem merged commit 2dbf833 into BabylonJS:master Sep 30, 2022
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