mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make sure that DeviceInfoModule is subscribed to LifecycleEventListener events, and unsubscribes in onCatalystInstanceDestroy
Summary: If modules are *not* eagerly init'd and expect lifecycle events, make sure (1) onHostResume is called immediately it it's currently active and (2) that listeners are removed in onCatalystInstanceDestroy. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26859157 fbshipit-source-id: 754a5b4ede8defa8b7742cc42e09cc7cbfe4e18d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
77a23bdf0f
commit
4f38973b06
+10
@@ -105,4 +105,14 @@ public class DeviceInfoModule extends NativeDeviceInfoSpec implements LifecycleE
|
||||
|
||||
@Override
|
||||
public void invalidate() {}
|
||||
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
super.onCatalystInstanceDestroy();
|
||||
|
||||
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
|
||||
if (applicationContext != null) {
|
||||
applicationContext.removeLifecycleEventListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user