From c8b37878dae980acb616fefccf2e8de930ff98e1 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 5 May 2021 16:40:40 -0700 Subject: [PATCH 1/5] Enable setJSResponder/setIsJSResponder for React Native --- .../src/ReactFabricGlobalResponderHandler.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js b/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js index e9aae2e4fd265..9bcc2a419b80d 100644 --- a/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js +++ b/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js @@ -19,7 +19,15 @@ 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; From fbbc2e5d4092655fe90ba44d0886604962594d05 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 5 May 2021 16:54:42 -0700 Subject: [PATCH 2/5] yarn prettier --- .../src/ReactFabricGlobalResponderHandler.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js b/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js index 9bcc2a419b80d..e6d1a68465e4e 100644 --- a/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js +++ b/packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js @@ -21,12 +21,20 @@ const ReactFabricGlobalResponderHandler = { if (isFabric) { if (from) { // equivalent to clearJSResponder - nativeFabricUIManager.setIsJSResponder(from.stateNode.node, false, blockNativeResponder || false); + nativeFabricUIManager.setIsJSResponder( + from.stateNode.node, + false, + blockNativeResponder || false, + ); } if (to) { // equivalent to setJSResponder - nativeFabricUIManager.setIsJSResponder(to.stateNode.node, true, blockNativeResponder || false); + nativeFabricUIManager.setIsJSResponder( + to.stateNode.node, + true, + blockNativeResponder || false, + ); } } else { if (to !== null) { From ca1f0ac7b56a258f9098afc187c0d28946e3c9f6 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 5 May 2021 16:58:47 -0700 Subject: [PATCH 3/5] add types to react-native-host-hooks --- scripts/flow/react-native-host-hooks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js index 17cc6fe9c952e..f4c7b747799c9 100644 --- a/scripts/flow/react-native-host-hooks.js +++ b/scripts/flow/react-native-host-hooks.js @@ -179,6 +179,7 @@ declare var nativeFabricUIManager: { locationY: number, callback: (Fiber) => void, ) => void, + setIsJSResponder: (node: Node, isJsResponder: boolean, blockNativeResponder: boolean) => void, ... }; From 1633a322562a6e46fc10ad2122c4f593abfce73b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 5 May 2021 16:59:10 -0700 Subject: [PATCH 4/5] yarn prettier --- scripts/flow/react-native-host-hooks.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js index f4c7b747799c9..92f766dfad415 100644 --- a/scripts/flow/react-native-host-hooks.js +++ b/scripts/flow/react-native-host-hooks.js @@ -179,7 +179,11 @@ declare var nativeFabricUIManager: { locationY: number, callback: (Fiber) => void, ) => void, - setIsJSResponder: (node: Node, isJsResponder: boolean, blockNativeResponder: boolean) => void, + setIsJSResponder: ( + node: Node, + isJsResponder: boolean, + blockNativeResponder: boolean, + ) => void, ... }; From 294c542cd99f3e5a7b19fff03e16737d0cb2cff7 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 5 May 2021 17:01:25 -0700 Subject: [PATCH 5/5] mock setIsJSResponder --- .../Libraries/ReactPrivate/InitializeNativeFabricUIManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager.js b/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager.js index 686dc72702de9..ee3c7df98508d 100644 --- a/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager.js +++ b/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager.js @@ -176,6 +176,7 @@ const RCTFabricUIManager = { ); success(1, 1, 100, 100); }), + setIsJSResponder: jest.fn(), }; global.nativeFabricUIManager = RCTFabricUIManager;