Skip to content

Commit

Permalink
Revert "Hold host functions in var" (#26079)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sammy-SC authored Jan 30, 2023
1 parent b0671f9 commit 9b1423c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 31 deletions.
9 changes: 2 additions & 7 deletions packages/react-native-renderer/src/ReactFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ import {LegacyRoot, ConcurrentRoot} from 'react-reconciler/src/ReactRootTags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import getComponentNameFromType from 'shared/getComponentNameFromType';

const {
dispatchCommand: fabricDispatchCommand,
sendAccessibilityEvent: fabricSendAccessibilityEvent,
} = nativeFabricUIManager;

const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;

function findHostInstance_DEPRECATED<TElementType: ElementType>(
Expand Down Expand Up @@ -173,7 +168,7 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
fabricDispatchCommand(stateNode.node, command, args);
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
}
} else {
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
Expand All @@ -194,7 +189,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
fabricSendAccessibilityEvent(stateNode.node, eventType);
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
}
} else {
legacySendAccessibilityEvent(handle._nativeTag, eventType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
// Module provided by RN:
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const {setIsJSResponder} = nativeFabricUIManager;

const ReactFabricGlobalResponderHandler = {
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
const fromOrTo = from || to;
Expand All @@ -23,7 +21,7 @@ const ReactFabricGlobalResponderHandler = {
if (isFabric) {
if (from) {
// equivalent to clearJSResponder
setIsJSResponder(
nativeFabricUIManager.setIsJSResponder(
from.stateNode.node,
false,
blockNativeResponder || false,
Expand All @@ -32,7 +30,7 @@ const ReactFabricGlobalResponderHandler = {

if (to) {
// equivalent to setJSResponder
setIsJSResponder(
nativeFabricUIManager.setIsJSResponder(
to.stateNode.node,
true,
blockNativeResponder || false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ if (__DEV__) {
Object.freeze(emptyObject);
}

const {measure, findNodeAtPoint} = nativeFabricUIManager;

let createHierarchy;
let getHostNode;
let getHostProps;
Expand Down Expand Up @@ -56,7 +54,7 @@ if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
hostFiber.stateNode.node;

if (shadowNode) {
measure(shadowNode, callback);
nativeFabricUIManager.measure(shadowNode, callback);
} else {
return UIManager.measure(
getHostNode(fiber, findNodeHandle),
Expand Down Expand Up @@ -202,7 +200,7 @@ if (__DEV__) {

if (inspectedView._internalInstanceHandle != null) {
// For Fabric we can look up the instance handle directly and measure it.
findNodeAtPoint(
nativeFabricUIManager.findNodeAtPoint(
inspectedView._internalInstanceHandle.stateNode.node,
locationX,
locationY,
Expand All @@ -222,7 +220,7 @@ if (__DEV__) {
const nativeViewTag =
internalInstanceHandle.stateNode.canonical._nativeTag;

measure(
nativeFabricUIManager.measure(
internalInstanceHandle.stateNode.node,
(x, y, width, height, pageX, pageY) => {
const inspectorData = getInspectorDataForInstance(
Expand Down
9 changes: 2 additions & 7 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ import getComponentNameFromType from 'shared/getComponentNameFromType';

const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;

const {
sendAccessibilityEvent: fabricSendAccessibilityEvent,
dispatchCommand: fabricDispatchCommand,
} = nativeFabricUIManager;

function findHostInstance_DEPRECATED(
componentOrHandle: any,
): ?React$ElementRef<HostComponent<mixed>> {
Expand Down Expand Up @@ -170,7 +165,7 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
fabricDispatchCommand(stateNode.node, command, args);
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
}
} else {
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
Expand All @@ -191,7 +186,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
fabricSendAccessibilityEvent(stateNode.node, eventType);
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
}
} else {
legacySendAccessibilityEvent(handle._nativeTag, eventType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('ReactNativeError', () => {
beforeEach(() => {
jest.resetModules();

require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');

React = require('react');
ReactNative = require('react-native-renderer');
createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ const fakeRequireNativeComponent = (uiViewClassName, validAttributes) => {
beforeEach(() => {
jest.resetModules();

require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');

PropTypes = require('prop-types');
RCTEventEmitter = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
.RCTEventEmitter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ describe('ReactNative', () => {
beforeEach(() => {
jest.resetModules();

require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');

React = require('react');
StrictMode = React.StrictMode;
ReactNative = require('react-native-renderer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ describe('createReactNativeComponentClass', () => {
beforeEach(() => {
jest.resetModules();

require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');

createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
.ReactNativeViewConfigRegistry.register;
React = require('react');
Expand Down

0 comments on commit 9b1423c

Please sign in to comment.