GeezerVison is showing github.com — Fabric-compatible implementation of `JSReponder` feature (#20768) · react/react@78d2f2d
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/react-native-renderer/src __mocks__/react-native/Libraries/ReactPrivate
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js +17-4Lines changed: 17 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,11 +12,24 @@ import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateI |
12 | 12 |
|
13 | 13 | const ReactFabricGlobalResponderHandler = { |
14 | 14 | onChange: function(from: any, to: any, blockNativeResponder: boolean) { |
15 | | - if (to !== null) { |
16 | | - const tag = to.stateNode.canonical._nativeTag; |
17 | | - UIManager.setJSResponder(tag, blockNativeResponder); |
| 15 | + const fromOrTo = from || to; |
| 16 | + const isFabric = !!fromOrTo.stateNode.canonical._internalInstanceHandle; |
| 17 | + |
| 18 | + if (isFabric) { |
| 19 | + if (from) { |
| 20 | + nativeFabricUIManager.setIsJSResponder(from.stateNode.node, false); |
| 21 | + } |
| 22 | + |
| 23 | + if (to) { |
| 24 | + nativeFabricUIManager.setIsJSResponder(to.stateNode.node, true); |
| 25 | + } |
18 | 26 | } else { |
19 | | - UIManager.clearJSResponder(); |
| 27 | + if (to !== null) { |
| 28 | + const tag = to.stateNode.canonical._nativeTag; |
| 29 | + UIManager.setJSResponder(tag, blockNativeResponder); |
| 30 | + } else { |
| 31 | + UIManager.clearJSResponder(); |
| 32 | + } |
20 | 33 | } |
21 | 34 | }, |
22 | 35 | }; |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -176,6 +176,7 @@ const RCTFabricUIManager = { |
176 | 176 | ); |
177 | 177 | success(1, 1, 100, 100); |
178 | 178 | }), |
| 179 | + setIsJSResponder: jest.fn(), |
179 | 180 | }; |
180 | 181 |
|
181 | 182 | global.nativeFabricUIManager = RCTFabricUIManager; |
Collapse file
Copy file name to clipboardExpand all lines: scripts/flow/react-native-host-hooks.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -179,6 +179,7 @@ declare var nativeFabricUIManager: { |
179 | 179 | locationY: number, |
180 | 180 | callback: (Fiber) => void, |
181 | 181 | ) => void, |
| 182 | + setIsJSResponder: (node: Node, isJsResponder: boolean) => void, |
182 | 183 | ... |
183 | 184 | }; |
184 | 185 |
|
|