mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make sure that NativeAnimatedModule 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: D26859158 fbshipit-source-id: 4966d3c49d194c4cb4063edf3a035f6077b76cd9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aa305b34e3
commit
014c6f9636
@@ -163,7 +163,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
|
||||
ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn();
|
||||
|
||||
if (reactApplicationContext != null) {
|
||||
reactApplicationContext.addLifecycleEventListener(this);
|
||||
reactApplicationContext.addLifecycleEventListenerAndCheckState(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,4 +891,12 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
ReactApplicationContext context = getReactApplicationContextIfActiveOrWarn();
|
||||
if (context != null) {
|
||||
context.removeLifecycleEventListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user