Skip to content

Commit

Permalink
Enable setJSResponder/setIsJSResponder for React Native Fabric (#21439)
Browse files Browse the repository at this point in the history
* Enable setJSResponder/setIsJSResponder for React Native

* yarn prettier

* add types to react-native-host-hooks

* yarn prettier

* mock setIsJSResponder
  • Loading branch information
JoshuaGross committed May 6, 2021
1 parent 46ef1ab commit bd070eb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Expand Up @@ -19,7 +19,23 @@ const ReactFabricGlobalResponderHandler = {
);

if (isFabric) {
// Noop for now until setJSResponder/clearJSResponder are supported in Fabric
if (from) {
// equivalent to clearJSResponder
nativeFabricUIManager.setIsJSResponder(
from.stateNode.node,
false,
blockNativeResponder || false,
);
}

if (to) {
// equivalent to setJSResponder
nativeFabricUIManager.setIsJSResponder(
to.stateNode.node,
true,
blockNativeResponder || false,
);
}
} else {
if (to !== null) {
const tag = to.stateNode.canonical._nativeTag;
Expand Down
Expand Up @@ -176,6 +176,7 @@ const RCTFabricUIManager = {
);
success(1, 1, 100, 100);
}),
setIsJSResponder: jest.fn(),
};

global.nativeFabricUIManager = RCTFabricUIManager;
5 changes: 5 additions & 0 deletions scripts/flow/react-native-host-hooks.js
Expand Up @@ -179,6 +179,11 @@ declare var nativeFabricUIManager: {
locationY: number,
callback: (Fiber) => void,
) => void,
setIsJSResponder: (
node: Node,
isJsResponder: boolean,
blockNativeResponder: boolean,
) => void,
...
};

Expand Down

0 comments on commit bd070eb

Please sign in to comment.