Clean listeners during destroy of ReactContext

Summary:
This diff cleans listeners on the destruction of the ReactContext.

changelog: [inernal] internal

Reviewed By: JoshuaGross

Differential Revision: D26259929

fbshipit-source-id: 1843cabdac2fa3e67dcc890afd923b82472d8f66
This commit is contained in:
David Vacca
2021-02-06 23:02:02 -08:00
committed by Facebook GitHub Bot
parent 98165a23f6
commit d79212120b
5 changed files with 22 additions and 4 deletions
@@ -23,6 +23,7 @@ import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.config.ReactFeatureFlags;
import java.lang.ref.WeakReference;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -296,6 +297,11 @@ public class ReactContext extends ContextWrapper {
if (mCatalystInstance != null) {
mCatalystInstance.destroy();
}
if (ReactFeatureFlags.enableReactContextCleanupFix) {
mLifecycleEventListeners.clear();
mActivityEventListeners.clear();
mWindowFocusEventListeners.clear();
}
}
/** Should be called by the hosting Fragment in {@link Fragment#onActivityResult} */