Avoid loading FabricUIManager from UIManagerModule in setJSResponder method

Summary:
In D8515300 we used the uiManagerType to call the setJSResponder method in UIImplementation or FabricUIManager.
There is a small chance that one of the reactTags received by parameter belongs to a View that is not managed by ReactNative, in that case we could be try to use FabricUIManager from UIManagerModule when Fabric is not running yet, causing a RN crash.
The fix consists in keep calling the UIImplementation.setJSResponder() method for any reactTag, and then perform a NOOP if the ReactShadowNode can not be found.

Reviewed By: fkgozali

Differential Revision: D8518192

fbshipit-source-id: 954fdd5dbed758ef73c16dad7da6b59ed83fe46a
This commit is contained in:
David Vacca
2018-06-19 14:35:28 -07:00
committed by Facebook Github Bot
parent 76eebce3c2
commit 73c4df219a
2 changed files with 8 additions and 9 deletions

View File

@@ -776,8 +776,14 @@ public class UIImplementation {
}
public void setJSResponder(int reactTag, boolean blockNativeResponder) {
assertViewExists(reactTag, "setJSResponder");
ReactShadowNode node = mShadowNodeRegistry.getNode(reactTag);
if (node == null) {
//TODO: this should only happen when using Fabric renderer. This is a temporary approach
//and it will be refactored when fabric supports JS Responder.
return;
}
while (node.isVirtual() || node.isLayoutOnly()) {
node = node.getParent();
}

View File

@@ -586,14 +586,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
@Override
@ReactMethod
public void setJSResponder(int reactTag, boolean blockNativeResponder) {
//TODO: this is a temporary approach to support ViewManagerCommands in Fabric until
// the dispatchViewManagerCommand() method is supported by Fabric JS API.
int uiManagerType = ViewUtil.getUIManagerType(reactTag);
if (uiManagerType != DEFAULT) {
UIManagerHelper.getUIManager(getReactApplicationContext(), uiManagerType).setJSResponder(reactTag, blockNativeResponder);
} else {
mUIImplementation.setJSResponder(reactTag, blockNativeResponder);
}
mUIImplementation.setJSResponder(reactTag, blockNativeResponder);
}
@Override