mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
+1
@@ -176,6 +176,7 @@ const RCTFabricUIManager = {
|
||||
);
|
||||
success(1, 1, 100, 100);
|
||||
}),
|
||||
setIsJSResponder: jest.fn(),
|
||||
};
|
||||
|
||||
global.nativeFabricUIManager = RCTFabricUIManager;
|
||||
|
||||
+1
@@ -179,6 +179,7 @@ declare var nativeFabricUIManager: {
|
||||
locationY: number,
|
||||
callback: (Fiber) => void,
|
||||
) => void,
|
||||
setIsJSResponder: (node: Node, isJsResponder: boolean) => void,
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user