Skip to content

Commit

Permalink
Remove last direct references to utilities in Paper from react-native
Browse files Browse the repository at this point in the history
Summary:
Changelog: [internal]

This replaces all direct references to the `ReactNative` module (which is the Paper renderer) to `RendererProxy` which would select between Paper and Fabric correctly.

The implementation of these functions is exactly the same right now.

As per the removal of the fix for T55744311 in `ScrollView`, I verified this doesn't cause any issues in the screen where it failed before.

Reviewed By: javache

Differential Revision: D39270691

fbshipit-source-id: 03882748fe4b754b9a2c5e9d4c4f003b94ed49ef
  • Loading branch information
rubennorte authored and facebook-github-bot committed Sep 8, 2022
1 parent 699dabb commit 4d04b1d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
import {sendAccessibilityEvent} from '../../Renderer/shims/ReactNative';
import {sendAccessibilityEvent} from '../../ReactNative/RendererProxy';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import Platform from '../../Utilities/Platform';
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ 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'
? {
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Components/Touchable/TouchableNativeFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Pressability, {
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import {Commands} from 'react-native/Libraries/Components/View/ViewNativeComponent';
import ReactNative from 'react-native/Libraries/Renderer/shims/ReactNative';
import {findHostInstance_DEPRECATED} from '../../ReactNative/RendererProxy';
import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';
import Platform from '../../Utilities/Platform';
import View from '../../Components/View/View';
Expand Down Expand Up @@ -206,7 +206,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {

_dispatchPressedStateChange(pressed: boolean): void {
if (Platform.OS === 'android') {
const hostComponentRef = ReactNative.findHostInstance_DEPRECATED(this);
const hostComponentRef = findHostInstance_DEPRECATED(this);
if (hostComponentRef == null) {
console.warn(
'Touchable: Unable to find HostComponent instance. ' +
Expand All @@ -221,7 +221,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
_dispatchHotspotUpdate(event: PressEvent): void {
if (Platform.OS === 'android') {
const {locationX, locationY} = event.nativeEvent;
const hostComponentRef = ReactNative.findHostInstance_DEPRECATED(this);
const hostComponentRef = findHostInstance_DEPRECATED(this);
if (hostComponentRef == null) {
console.warn(
'Touchable: Unable to find HostComponent instance. ' +
Expand Down
11 changes: 1 addition & 10 deletions Libraries/Utilities/codegenNativeCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
* @flow
*/

let dispatchCommand;
if (global.RN$Bridgeless) {
// Note: this function has the same implementation in the legacy and new renderer.
// However, evaluating the old renderer comes with some side effects.
dispatchCommand =
require('../../Libraries/Renderer/shims/ReactFabric').dispatchCommand;
} else {
dispatchCommand =
require('../../Libraries/Renderer/shims/ReactNative').dispatchCommand;
}
const {dispatchCommand} = require('../ReactNative/RendererProxy');

type Options<T = string> = $ReadOnly<{|
supportedCommands: $ReadOnlyArray<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
const {
dispatchCommand
} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
let nativeComponentName = 'RCTModule';
export const __INTERNAL_VIEW_CONFIG = {
Expand Down Expand Up @@ -99,7 +99,7 @@ const {
const {
dispatchCommand
} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
let nativeComponentName = 'RCTModule';
export const __INTERNAL_VIEW_CONFIG = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function buildCommands(
}

imports.add(
'const {dispatchCommand} = require("react-native/Libraries/Renderer/shims/ReactNative");',
'const {dispatchCommand} = require("react-native/Libraries/ReactNative/RendererProxy");',
);

const properties = commands.map(command => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
const {dispatchCommand} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
let nativeComponentName = 'CommandNativeComponent';
Expand Down Expand Up @@ -211,7 +211,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
const {dispatchCommand} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
let nativeComponentName = 'CommandNativeComponent';
Expand Down

0 comments on commit 4d04b1d

Please sign in to comment.