Files
react-native/packages
Moti Zilberman bbf8a87ce7 Defer HostTarget destruction until after the instance has been unregistered (#44767)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44767

Changelog: [Internal]

Fixes a lifecycle bug in both the Bridge (`com.facebook.react.bridge`) and Bridgeless (`com.facebook.react.runtime`) integrations of Fusebox in React Native Android, whereby `HostTarget::unregisterInstance` gets called after the `HostTarget` has been destroyed.

The solution consists of two parts:

1. If a ReactHost / InstanceManager is asked to destroy itself while it contains no active ReactInstance / ReactContext, we destroy the `HostTarget` immediately.
2. Otherwise, if there *is* a live ReactInstance / ReactContext that has yet to be destroyed, we wait for that to happen before destroying the `HostTarget`. In practice, we do this by checking for the BEFORE_CREATE ( = Host destroyed) lifecycle state every time we destroy a ReactInstance / ReactContext.

Reviewed By: javache

Differential Revision: D58031215

fbshipit-source-id: 321c73e85afd17a1b38c63f73aee5ebb59c00686
2024-06-06 07:38:23 -07:00
..
2024-06-03 06:01:43 -07:00
2024-04-24 12:27:04 -07:00