Skip to content

Commit 9b1423c

Browse files
authored
Revert "Hold host functions in var" (#26079)
Revert 353c30252. The commit breaks old React Native where `nativeFabricUIManager` is undefined. I need to add unit test for this to make sure it doesn't happen in the future and create a mechanism to deal with undefined `nativeFabricUIManager`. This is to unblock React sync to React Native.
1 parent b0671f9 commit 9b1423c

8 files changed

+9
-31
lines changed

packages/react-native-renderer/src/ReactFabric.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ import {LegacyRoot, ConcurrentRoot} from 'react-reconciler/src/ReactRootTags';
4444
import ReactSharedInternals from 'shared/ReactSharedInternals';
4545
import getComponentNameFromType from 'shared/getComponentNameFromType';
4646

47-
const {
48-
dispatchCommand: fabricDispatchCommand,
49-
sendAccessibilityEvent: fabricSendAccessibilityEvent,
50-
} = nativeFabricUIManager;
51-
5247
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
5348

5449
function findHostInstance_DEPRECATED<TElementType: ElementType>(
@@ -173,7 +168,7 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
173168
if (handle._internalInstanceHandle != null) {
174169
const {stateNode} = handle._internalInstanceHandle;
175170
if (stateNode != null) {
176-
fabricDispatchCommand(stateNode.node, command, args);
171+
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
177172
}
178173
} else {
179174
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
@@ -194,7 +189,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
194189
if (handle._internalInstanceHandle != null) {
195190
const {stateNode} = handle._internalInstanceHandle;
196191
if (stateNode != null) {
197-
fabricSendAccessibilityEvent(stateNode.node, eventType);
192+
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
198193
}
199194
} else {
200195
legacySendAccessibilityEvent(handle._nativeTag, eventType);

packages/react-native-renderer/src/ReactFabricGlobalResponderHandler.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// Module provided by RN:
1111
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
1212

13-
const {setIsJSResponder} = nativeFabricUIManager;
14-
1513
const ReactFabricGlobalResponderHandler = {
1614
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
1715
const fromOrTo = from || to;
@@ -23,7 +21,7 @@ const ReactFabricGlobalResponderHandler = {
2321
if (isFabric) {
2422
if (from) {
2523
// equivalent to clearJSResponder
26-
setIsJSResponder(
24+
nativeFabricUIManager.setIsJSResponder(
2725
from.stateNode.node,
2826
false,
2927
blockNativeResponder || false,
@@ -32,7 +30,7 @@ const ReactFabricGlobalResponderHandler = {
3230

3331
if (to) {
3432
// equivalent to setJSResponder
35-
setIsJSResponder(
33+
nativeFabricUIManager.setIsJSResponder(
3634
to.stateNode.node,
3735
true,
3836
blockNativeResponder || false,

packages/react-native-renderer/src/ReactNativeFiberInspector.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ if (__DEV__) {
2626
Object.freeze(emptyObject);
2727
}
2828

29-
const {measure, findNodeAtPoint} = nativeFabricUIManager;
30-
3129
let createHierarchy;
3230
let getHostNode;
3331
let getHostProps;
@@ -56,7 +54,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
5654
hostFiber.stateNode.node;
5755

5856
if (shadowNode) {
59-
measure(shadowNode, callback);
57+
nativeFabricUIManager.measure(shadowNode, callback);
6058
} else {
6159
return UIManager.measure(
6260
getHostNode(fiber, findNodeHandle),
@@ -202,7 +200,7 @@ if (__DEV__) {
202200

203201
if (inspectedView._internalInstanceHandle != null) {
204202
// For Fabric we can look up the instance handle directly and measure it.
205-
findNodeAtPoint(
203+
nativeFabricUIManager.findNodeAtPoint(
206204
inspectedView._internalInstanceHandle.stateNode.node,
207205
locationX,
208206
locationY,
@@ -222,7 +220,7 @@ if (__DEV__) {
222220
const nativeViewTag =
223221
internalInstanceHandle.stateNode.canonical._nativeTag;
224222

225-
measure(
223+
nativeFabricUIManager.measure(
226224
internalInstanceHandle.stateNode.node,
227225
(x, y, width, height, pageX, pageY) => {
228226
const inspectorData = getInspectorDataForInstance(

packages/react-native-renderer/src/ReactNativeRenderer.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ import getComponentNameFromType from 'shared/getComponentNameFromType';
4949

5050
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
5151

52-
const {
53-
sendAccessibilityEvent: fabricSendAccessibilityEvent,
54-
dispatchCommand: fabricDispatchCommand,
55-
} = nativeFabricUIManager;
56-
5752
function findHostInstance_DEPRECATED(
5853
componentOrHandle: any,
5954
): ?React$ElementRef<HostComponent<mixed>> {
@@ -170,7 +165,7 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
170165
if (handle._internalInstanceHandle != null) {
171166
const {stateNode} = handle._internalInstanceHandle;
172167
if (stateNode != null) {
173-
fabricDispatchCommand(stateNode.node, command, args);
168+
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
174169
}
175170
} else {
176171
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
@@ -191,7 +186,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
191186
if (handle._internalInstanceHandle != null) {
192187
const {stateNode} = handle._internalInstanceHandle;
193188
if (stateNode != null) {
194-
fabricSendAccessibilityEvent(stateNode.node, eventType);
189+
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
195190
}
196191
} else {
197192
legacySendAccessibilityEvent(handle._nativeTag, eventType);

packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ describe('ReactNativeError', () => {
2828
beforeEach(() => {
2929
jest.resetModules();
3030

31-
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
32-
3331
React = require('react');
3432
ReactNative = require('react-native-renderer');
3533
createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')

packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ const fakeRequireNativeComponent = (uiViewClassName, validAttributes) => {
6363
beforeEach(() => {
6464
jest.resetModules();
6565

66-
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
67-
6866
PropTypes = require('prop-types');
6967
RCTEventEmitter = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
7068
.RCTEventEmitter;

packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ describe('ReactNative', () => {
3030
beforeEach(() => {
3131
jest.resetModules();
3232

33-
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
34-
3533
React = require('react');
3634
StrictMode = React.StrictMode;
3735
ReactNative = require('react-native-renderer');

packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.internal.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ describe('createReactNativeComponentClass', () => {
1818
beforeEach(() => {
1919
jest.resetModules();
2020

21-
require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
22-
2321
createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
2422
.ReactNativeViewConfigRegistry.register;
2523
React = require('react');

0 commit comments

Comments
 (0)