mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use findNodeHandle from RendererProxy instead of Paper in usages within the react-native package
Summary: This replaces all direct references to `ReactNative` within the `react-native` package to use `findNodeHandle` with a reference obtained from `RendererProxy`, which will allow us to select the correct renderer. Changelog: [internal] Reviewed By: javache Differential Revision: D39270689 fbshipit-source-id: a39875281ba7b7b1b00128564124b6adcacebc4d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b06cae3681
commit
699dabb2e3
@@ -13,7 +13,7 @@
|
||||
const AnimatedValue = require('./nodes/AnimatedValue');
|
||||
const AnimatedValueXY = require('./nodes/AnimatedValueXY');
|
||||
const NativeAnimatedHelper = require('./NativeAnimatedHelper');
|
||||
const ReactNative = require('../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../ReactNative/RendererProxy');
|
||||
|
||||
const invariant = require('invariant');
|
||||
|
||||
@@ -67,7 +67,7 @@ function attachNativeEvent(
|
||||
// Assume that the event containing `nativeEvent` is always the first argument.
|
||||
traverse(argMapping[0].nativeEvent, []);
|
||||
|
||||
const viewTag = ReactNative.findNodeHandle(viewRef);
|
||||
const viewTag = findNodeHandle(viewRef);
|
||||
if (viewTag != null) {
|
||||
eventMappings.forEach(mapping => {
|
||||
NativeAnimatedHelper.API.addAnimatedEventToView(
|
||||
|
||||
@@ -20,8 +20,8 @@ jest
|
||||
}))
|
||||
.mock('../NativeAnimatedModule')
|
||||
.mock('../../EventEmitter/NativeEventEmitter')
|
||||
// findNodeHandle is imported from ReactNative so mock that whole module.
|
||||
.setMock('../../Renderer/shims/ReactNative', {findNodeHandle: () => 1});
|
||||
// findNodeHandle is imported from RendererProxy so mock that whole module.
|
||||
.setMock('../../ReactNative/RendererProxy', {findNodeHandle: () => 1});
|
||||
|
||||
import TestRenderer from 'react-test-renderer';
|
||||
import * as React from 'react';
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
||||
|
||||
const ReactNative = require('../../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../../ReactNative/RendererProxy');
|
||||
const {AnimatedEvent} = require('../AnimatedEvent');
|
||||
const NativeAnimatedHelper = require('../NativeAnimatedHelper');
|
||||
const AnimatedNode = require('./AnimatedNode');
|
||||
@@ -134,9 +134,7 @@ class AnimatedProps extends AnimatedNode {
|
||||
|
||||
__connectAnimatedView(): void {
|
||||
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
||||
const nativeViewTag: ?number = ReactNative.findNodeHandle(
|
||||
this._animatedView,
|
||||
);
|
||||
const nativeViewTag: ?number = findNodeHandle(this._animatedView);
|
||||
invariant(
|
||||
nativeViewTag != null,
|
||||
'Unable to locate attached view in the native tree',
|
||||
@@ -149,9 +147,7 @@ class AnimatedProps extends AnimatedNode {
|
||||
|
||||
__disconnectAnimatedView(): void {
|
||||
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
||||
const nativeViewTag: ?number = ReactNative.findNodeHandle(
|
||||
this._animatedView,
|
||||
);
|
||||
const nativeViewTag: ?number = findNodeHandle(this._animatedView);
|
||||
invariant(
|
||||
nativeViewTag != null,
|
||||
'Unable to locate attached view in the native tree',
|
||||
|
||||
@@ -12,8 +12,7 @@ import AnimatedImplementation from '../../Animated/AnimatedImplementation';
|
||||
import Dimensions from '../../Utilities/Dimensions';
|
||||
import Platform from '../../Utilities/Platform';
|
||||
import * as React from 'react';
|
||||
import ReactNative from '../../Renderer/shims/ReactNative';
|
||||
require('../../Renderer/shims/ReactNative'); // Force side effects to prevent T55744311
|
||||
import {findNodeHandle} from '../../ReactNative/RendererProxy';
|
||||
import ScrollViewStickyHeader from './ScrollViewStickyHeader';
|
||||
import StyleSheet from '../../StyleSheet/StyleSheet';
|
||||
import View from '../View/View';
|
||||
@@ -51,6 +50,8 @@ import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrol
|
||||
import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent';
|
||||
import ScrollViewNativeComponent from './ScrollViewNativeComponent';
|
||||
|
||||
require('../../Renderer/shims/ReactNative'); // Force side effects to prevent T55744311
|
||||
|
||||
const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} =
|
||||
Platform.OS === 'android'
|
||||
? {
|
||||
@@ -867,11 +868,11 @@ class ScrollView extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
getScrollableNode: () => ?number = () => {
|
||||
return ReactNative.findNodeHandle(this._scrollViewRef);
|
||||
return findNodeHandle(this._scrollViewRef);
|
||||
};
|
||||
|
||||
getInnerViewNode: () => ?number = () => {
|
||||
return ReactNative.findNodeHandle(this._innerViewRef);
|
||||
return findNodeHandle(this._innerViewRef);
|
||||
};
|
||||
|
||||
getInnerViewRef: () => ?React.ElementRef<typeof View> = () => {
|
||||
@@ -996,7 +997,7 @@ class ScrollView extends React.Component<Props, State> {
|
||||
if (typeof nodeHandle === 'number') {
|
||||
UIManager.measureLayout(
|
||||
nodeHandle,
|
||||
ReactNative.findNodeHandle(this),
|
||||
findNodeHandle(this),
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this._textInputFocusError,
|
||||
this._inputMeasureAndScrollToKeyboard,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
const React = require('react');
|
||||
const Platform = require('../../Utilities/Platform');
|
||||
const {findNodeHandle} = require('../../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../../ReactNative/RendererProxy');
|
||||
import {Commands as AndroidTextInputCommands} from '../../Components/TextInput/AndroidTextInputNativeComponent';
|
||||
import {Commands as iOSTextInputCommands} from '../../Components/TextInput/RCTSingelineTextInputNativeComponent';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
const React = require('react');
|
||||
const ReactTestRenderer = require('react-test-renderer');
|
||||
const TextInput = require('../TextInput');
|
||||
const ReactNative = require('../../../Renderer/shims/ReactNative');
|
||||
const ReactNative = require('../../../ReactNative/RendererProxy');
|
||||
|
||||
const {
|
||||
enter,
|
||||
|
||||
@@ -15,7 +15,7 @@ import View from '../Components/View/View';
|
||||
import StyleSheet from '../StyleSheet/StyleSheet';
|
||||
import Dimensions from '../Utilities/Dimensions';
|
||||
const getInspectorDataForViewAtPoint = require('./getInspectorDataForViewAtPoint');
|
||||
const ReactNative = require('../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../ReactNative/RendererProxy');
|
||||
|
||||
import type {HostRef} from './getInspectorDataForViewAtPoint';
|
||||
|
||||
@@ -123,7 +123,7 @@ export default function DevtoolsOverlay({
|
||||
viewData => {
|
||||
const {touchedViewTag} = viewData;
|
||||
if (touchedViewTag != null) {
|
||||
agent.selectNode(ReactNative.findNodeHandle(touchedViewTag));
|
||||
agent.selectNode(findNodeHandle(touchedViewTag));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -16,7 +16,7 @@ const InspectorPanel = require('./InspectorPanel');
|
||||
const Platform = require('../Utilities/Platform');
|
||||
const PressabilityDebug = require('../Pressability/PressabilityDebug');
|
||||
const React = require('react');
|
||||
const ReactNative = require('../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../ReactNative/RendererProxy');
|
||||
const StyleSheet = require('../StyleSheet/StyleSheet');
|
||||
const View = require('../Components/View/View');
|
||||
const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes');
|
||||
@@ -110,10 +110,9 @@ class Inspector extends React.Component<
|
||||
|
||||
setSelection(i: number) {
|
||||
const hierarchyItem = this.state.hierarchy[i];
|
||||
// we pass in ReactNative.findNodeHandle as the method is injected
|
||||
const {measure, props, source} = hierarchyItem.getInspectorData(
|
||||
ReactNative.findNodeHandle,
|
||||
);
|
||||
// we pass in findNodeHandle as the method is injected
|
||||
const {measure, props, source} =
|
||||
hierarchyItem.getInspectorData(findNodeHandle);
|
||||
|
||||
measure((x, y, width, height, left, top) => {
|
||||
this.setState({
|
||||
@@ -143,9 +142,7 @@ class Inspector extends React.Component<
|
||||
// Note: This is Paper only. To support Fabric,
|
||||
// DevTools needs to be updated to not rely on view tags.
|
||||
if (this.state.devtoolsAgent && touchedViewTag) {
|
||||
this.state.devtoolsAgent.selectNode(
|
||||
ReactNative.findNodeHandle(touchedViewTag),
|
||||
);
|
||||
this.state.devtoolsAgent.selectNode(findNodeHandle(touchedViewTag));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
||||
@@ -41,7 +41,7 @@ const RefreshControl = require('../Components/RefreshControl/RefreshControl');
|
||||
const ScrollView = require('../Components/ScrollView/ScrollView');
|
||||
const View = require('../Components/View/View');
|
||||
const Batchinator = require('../Interaction/Batchinator');
|
||||
const ReactNative = require('../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../ReactNative/RendererProxy');
|
||||
const flattenStyle = require('../StyleSheet/flattenStyle');
|
||||
const StyleSheet = require('../StyleSheet/StyleSheet');
|
||||
const infoLog = require('../Utilities/infoLog');
|
||||
@@ -326,7 +326,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
if (this._scrollRef && this._scrollRef.getScrollableNode) {
|
||||
return this._scrollRef.getScrollableNode();
|
||||
} else {
|
||||
return ReactNative.findNodeHandle(this._scrollRef);
|
||||
return findNodeHandle(this._scrollRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ const RefreshControl = require('../Components/RefreshControl/RefreshControl');
|
||||
const ScrollView = require('../Components/ScrollView/ScrollView');
|
||||
const View = require('../Components/View/View');
|
||||
const Batchinator = require('../Interaction/Batchinator');
|
||||
const ReactNative = require('../Renderer/shims/ReactNative');
|
||||
const {findNodeHandle} = require('../ReactNative/RendererProxy');
|
||||
const flattenStyle = require('../StyleSheet/flattenStyle');
|
||||
const StyleSheet = require('../StyleSheet/StyleSheet');
|
||||
const infoLog = require('../Utilities/infoLog');
|
||||
@@ -347,7 +347,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
||||
if (this._scrollRef && this._scrollRef.getScrollableNode) {
|
||||
return this._scrollRef.getScrollableNode();
|
||||
} else {
|
||||
return ReactNative.findNodeHandle(this._scrollRef);
|
||||
return findNodeHandle(this._scrollRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user