Skip to content

Commit

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

* Enable setJSResponder/setIsJSResponder for React Native

* yarn prettier

* add types to react-native-host-hooks

* yarn prettier

* mock setIsJSResponder
  • Loading branch information
JoshuaGross authored and koto committed Jun 15, 2021
1 parent 1d2e81b commit 73f6f36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 73f6f36

Please sign in to comment.