Fabric-compatible implementation of JSReponder feature (#20768)

With this change, if a node is a Fabric node, we route the setJSResponder call to FabricUIManager. Native counterpart is already landed. Tested internally as D26241364.
This commit is contained in:
Valentin Shergin
2021-02-22 16:50:03 -05:00
committed by GitHub
parent 1375341bdc
commit df1f2a52ea
3 changed files with 19 additions and 4 deletions
@@ -12,11 +12,24 @@ import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateI
const ReactFabricGlobalResponderHandler = {
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
if (to !== null) {
const tag = to.stateNode.canonical._nativeTag;
UIManager.setJSResponder(tag, blockNativeResponder);
const fromOrTo = from || to;
const isFabric = !!fromOrTo.stateNode.canonical._internalInstanceHandle;
if (isFabric) {
if (from) {
nativeFabricUIManager.setIsJSResponder(from.stateNode.node, false);
}
if (to) {
nativeFabricUIManager.setIsJSResponder(to.stateNode.node, true);
}
} else {
UIManager.clearJSResponder();
if (to !== null) {
const tag = to.stateNode.canonical._nativeTag;
UIManager.setJSResponder(tag, blockNativeResponder);
} else {
UIManager.clearJSResponder();
}
}
},
};
@@ -176,6 +176,7 @@ const RCTFabricUIManager = {
);
success(1, 1, 100, 100);
}),
setIsJSResponder: jest.fn(),
};
global.nativeFabricUIManager = RCTFabricUIManager;
+1
View File
@@ -179,6 +179,7 @@ declare var nativeFabricUIManager: {
locationY: number,
callback: (Fiber) => void,
) => void,
setIsJSResponder: (node: Node, isJsResponder: boolean) => void,
...
};