mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-15 23:03:58 +08:00
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:
committed by
Facebook Github Bot
parent
76eebce3c2
commit
73c4df219a
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user