mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 09:30:10 +08:00
Queue JS calls that come in before JS bundle has started loading instead of crashing
Summary: This mimics (some of) the behavior we have on iOS where if you call a JS module method before the JS bundle has started loading, we just queue up those calls and execute them after the bundle has started loading. Reviewed By: javache Differential Revision: D4117581 fbshipit-source-id: 58c5a6f87aeeb86083385334d92f2716a0574ba1
This commit is contained in:
committed by
Facebook Github Bot
parent
52d90da75e
commit
68aeffe01f
@@ -40,7 +40,8 @@ public class ReactContext extends ContextWrapper {
|
||||
|
||||
private static final String EARLY_JS_ACCESS_EXCEPTION_MESSAGE =
|
||||
"Tried to access a JS module before the React instance was fully set up. Calls to " +
|
||||
"ReactContext#getJSModule should be protected by ReactContext#hasActiveCatalystInstance().";
|
||||
"ReactContext#getJSModule should only happen once initialize() has been called on your " +
|
||||
"native module.";
|
||||
|
||||
private final CopyOnWriteArraySet<LifecycleEventListener> mLifecycleEventListeners =
|
||||
new CopyOnWriteArraySet<>();
|
||||
@@ -143,7 +144,7 @@ public class ReactContext extends ContextWrapper {
|
||||
}
|
||||
|
||||
public boolean hasActiveCatalystInstance() {
|
||||
return mCatalystInstance != null && mCatalystInstance.isAcceptingCalls();
|
||||
return mCatalystInstance != null && !mCatalystInstance.isDestroyed();
|
||||
}
|
||||
|
||||
public LifecycleState getLifecycleState() {
|
||||
|
||||
Reference in New Issue
Block a user