-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unmount React applications when re-creating context [RFC] (#37004)
Summary: Pull Request resolved: #37004 Currently in RN Android when re-creating the context we don't unmount the underlying React application. This violates ViewManager and React hooks contracts, who are no longer able to properly unmount views, and instead the view hierarchy is forcefully torn down by Android UI. This differs from iOS, where we do unmount the application on reloads. This is a trade-off with performance, as we'll keep the JS thread alive slightly longer to complete shutdown, but it's the right call for correctness. It also only mainly affects development, as recreating the context is rare in production. Repro steps: ``` useEffect(() => { console.log('Playground useEffect invoked'); return () => { console.log('Playground useEffect destructor invoked'); }; }, []); ``` Validate that when reloading the application, the second console.log is printed. Changelog: [Android][Changed] React trees will be unmounted when the application is reloaded Reviewed By: luluwu2032 Differential Revision: D45145520 fbshipit-source-id: a4dcd2ff4a8fc14cb0f276a5ef9afe21d1104735
- Loading branch information
1 parent
4da2013
commit e133100
Showing
4 changed files
with
71 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...eact-native/ReactAndroid/src/main/java/com/facebook/react/modules/fabric/ReactFabric.java
This file was deleted.
Oops, something went wrong.