diff --git a/packages/react-native-renderer/src/NativeMethodsMixin.js b/packages/react-native-renderer/src/NativeMethodsMixin.js index 04f425fa839ad..27d928cee4c35 100644 --- a/packages/react-native-renderer/src/NativeMethodsMixin.js +++ b/packages/react-native-renderer/src/NativeMethodsMixin.js @@ -30,7 +30,6 @@ import { } from './NativeMethodsMixinUtils'; import warningWithoutStack from 'shared/warningWithoutStack'; -import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags'; export default function( findNodeHandle: any => ?number, @@ -251,18 +250,6 @@ export default function( return; } - if (__DEV__) { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack( - false, - 'Warning: Calling ref.setNativeProps(nativeProps) ' + - 'is deprecated and will be removed in a future release. ' + - 'Use the setNativeProps export from the react-native package instead.' + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n", - ); - } - } - const nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; const viewConfig: ReactNativeBaseComponentViewConfig<> = diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 72f7a46098191..f0311ed8b5c39 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -109,15 +109,6 @@ const ReactFabric: ReactFabricType = { findNodeHandle, - setNativeProps(handle: any, nativeProps: Object) { - warningWithoutStack( - false, - 'Warning: setNativeProps is not currently supported in Fabric', - ); - - return; - }, - dispatchCommand(handle: any, command: string, args: Array) { const invalid = handle._nativeTag == null || handle._internalInstanceHandle == null; diff --git a/packages/react-native-renderer/src/ReactNativeComponent.js b/packages/react-native-renderer/src/ReactNativeComponent.js index 8ac04ffea193a..52dfab958966b 100644 --- a/packages/react-native-renderer/src/ReactNativeComponent.js +++ b/packages/react-native-renderer/src/ReactNativeComponent.js @@ -27,7 +27,6 @@ import {create} from './ReactNativeAttributePayload'; import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils'; import warningWithoutStack from 'shared/warningWithoutStack'; -import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags'; export default function( findNodeHandle: any => ?number, @@ -262,18 +261,6 @@ export default function( return; } - if (__DEV__) { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack( - false, - 'Warning: Calling ref.setNativeProps(nativeProps) ' + - 'is deprecated and will be removed in a future release. ' + - 'Use the setNativeProps export from the react-native package instead.' + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n", - ); - } - } - const nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; const viewConfig: ReactNativeBaseComponentViewConfig<> = diff --git a/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js b/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js index b49b31008f740..4bee7c7e1089a 100644 --- a/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js +++ b/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js @@ -29,7 +29,6 @@ import { } from './NativeMethodsMixinUtils'; import warningWithoutStack from 'shared/warningWithoutStack'; -import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags'; /** * This component defines the same methods as NativeMethodsMixin but without the @@ -104,15 +103,6 @@ class ReactNativeFiberHostComponent { setNativeProps(nativeProps: Object) { if (__DEV__) { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack( - false, - 'Warning: Calling ref.setNativeProps(nativeProps) ' + - 'is deprecated and will be removed in a future release. ' + - 'Use the setNativeProps export from the react-native package instead.' + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n", - ); - } warnForStyleProps(nativeProps, this.viewConfig.validAttributes); } diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index 21ec4e239e2cd..bb1827a38fa0a 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -39,7 +39,6 @@ import NativeMethodsMixin from './NativeMethodsMixin'; import ReactNativeComponent from './ReactNativeComponent'; import {getClosestInstanceFromNode} from './ReactNativeComponentTree'; import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; -import {setNativeProps} from './ReactNativeRendererSharedExports'; import {LegacyRoot} from 'shared/ReactRootTags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; @@ -133,8 +132,6 @@ const ReactNativeRenderer: ReactNativeType = { UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args); }, - setNativeProps, - render(element: React$Element, containerTag: any, callback: ?Function) { let root = roots.get(containerTag); diff --git a/packages/react-native-renderer/src/ReactNativeRendererSharedExports.js b/packages/react-native-renderer/src/ReactNativeRendererSharedExports.js deleted file mode 100644 index f79f4d087c1ab..0000000000000 --- a/packages/react-native-renderer/src/ReactNativeRendererSharedExports.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import {create} from './ReactNativeAttributePayload'; -import {warnForStyleProps} from './NativeMethodsMixinUtils'; - -import warningWithoutStack from 'shared/warningWithoutStack'; - -// Module provided by RN: -import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; - -export function setNativeProps(handle: any, nativeProps: Object): void { - if (handle._nativeTag == null) { - warningWithoutStack( - handle._nativeTag != null, - "setNativeProps was called with a ref that isn't a " + - 'native component. Use React.forwardRef to get access to the underlying native component', - ); - return; - } - - if (__DEV__) { - warnForStyleProps(nativeProps, handle.viewConfig.validAttributes); - } - - const updatePayload = create(nativeProps, handle.viewConfig.validAttributes); - // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. - if (updatePayload != null) { - UIManager.updateView( - handle._nativeTag, - handle.viewConfig.uiViewClassName, - updatePayload, - ); - } -} diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index fe42de3c62a58..0ef08d294d8e5 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -143,7 +143,6 @@ export type ReactNativeType = { NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, dispatchCommand(handle: any, command: string, args: Array): void, - setNativeProps(handle: any, nativeProps: Object): void, render( element: React$Element, containerTag: any, @@ -160,7 +159,6 @@ export type ReactFabricType = { NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, dispatchCommand(handle: any, command: string, args: Array): void, - setNativeProps(handle: any, nativeProps: Object): void, render( element: React$Element, containerTag: any, diff --git a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js index cbfff45d4bf45..8474f0866d775 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js @@ -12,7 +12,6 @@ let React; let ReactFabric; -let ReactFeatureFlags; let createReactClass; let createReactNativeComponentClass; let UIManager; @@ -38,8 +37,6 @@ describe('ReactFabric', () => { React = require('react'); StrictMode = React.StrictMode; - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.warnAboutDeprecatedSetNativeProps = true; ReactFabric = require('react-native-renderer/fabric'); UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') .UIManager; @@ -338,84 +335,6 @@ describe('ReactFabric', () => { }); }); - it('setNativeProps on native refs should no-op', () => { - const View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {foo: true}, - uiViewClassName: 'RCTView', - })); - - UIManager.updateView.mockReset(); - - let viewRef; - ReactFabric.render( - { - viewRef = ref; - }} - />, - 11, - ); - - expect(UIManager.updateView).not.toBeCalled(); - expect(() => { - ReactFabric.setNativeProps(viewRef, {foo: 'baz'}); - }).toWarnDev([SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE], { - withoutStack: true, - }); - expect(UIManager.updateView).not.toBeCalled(); - }); - - it('should warn and no-op if calling setNativeProps on non native refs', () => { - const View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {foo: true}, - uiViewClassName: 'RCTView', - })); - - class BasicClass extends React.Component { - render() { - return ; - } - } - - class Subclass extends ReactFabric.NativeComponent { - render() { - return ; - } - } - - const CreateClass = createReactClass({ - mixins: [NativeMethodsMixin], - render: () => { - return ; - }, - }); - - [BasicClass, Subclass, CreateClass].forEach(Component => { - UIManager.updateView.mockReset(); - - let viewRef; - ReactFabric.render( - { - viewRef = ref; - }} - />, - 11, - ); - - expect(UIManager.updateView).not.toBeCalled(); - expect(() => { - ReactFabric.setNativeProps(viewRef, {foo: 'baz'}); - }).toWarnDev([SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE], { - withoutStack: true, - }); - - expect(UIManager.updateView).not.toBeCalled(); - }); - }); - it('should call FabricUIManager.measure on ref.measure', () => { const View = createReactNativeComponentClass('RCTView', () => ({ validAttributes: {foo: true}, diff --git a/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js index 10f3bda5522ef..ba15cd369ca55 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js @@ -73,24 +73,4 @@ describe('ReactFabric', () => { [10, 20], ); }); - - it('sets native props with setNativeProps on Fabric nodes with the RN renderer', () => { - UIManager.updateView.mockReset(); - const View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {title: true}, - uiViewClassName: 'RCTView', - })); - - let ref = React.createRef(); - - ReactFabric.render(, 11); - expect(UIManager.updateView).not.toBeCalled(); - ReactNative.setNativeProps(ref.current, {title: 'baz'}); - expect(UIManager.updateView).toHaveBeenCalledTimes(1); - expect(UIManager.updateView).toHaveBeenCalledWith( - expect.any(Number), - 'RCTView', - {title: 'baz'}, - ); - }); }); diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js index a22d9ee7e86c1..74b2700f80791 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js @@ -11,7 +11,6 @@ 'use strict'; let React; -let ReactFeatureFlags; let StrictMode; let ReactNative; let createReactClass; @@ -23,20 +22,12 @@ const DISPATCH_COMMAND_REQUIRES_HOST_COMPONENT = "Warning: dispatchCommand was called with a ref that isn't a " + 'native component. Use React.forwardRef to get access to the underlying native component'; -const SET_NATIVE_PROPS_DEPRECATION_MESSAGE = - 'Warning: Calling ref.setNativeProps(nativeProps) ' + - 'is deprecated and will be removed in a future release. ' + - 'Use the setNativeProps export from the react-native package instead.' + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"; - describe('ReactNative', () => { beforeEach(() => { jest.resetModules(); React = require('react'); StrictMode = React.StrictMode; - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.warnAboutDeprecatedSetNativeProps = true; ReactNative = require('react-native-renderer'); UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') .UIManager; @@ -223,21 +214,13 @@ describe('ReactNative', () => { />, 11, ); - expect(UIManager.updateView).not.toBeCalled(); - expect(() => { - viewRef.setNativeProps({}); - }).toWarnDev([SET_NATIVE_PROPS_DEPRECATION_MESSAGE], { - withoutStack: true, - }); expect(UIManager.updateView).not.toBeCalled(); - expect(() => { - viewRef.setNativeProps({foo: 'baz'}); - }).toWarnDev([SET_NATIVE_PROPS_DEPRECATION_MESSAGE], { - withoutStack: true, - }); + viewRef.setNativeProps({}); + expect(UIManager.updateView).not.toBeCalled(); + viewRef.setNativeProps({foo: 'baz'}); expect(UIManager.updateView).toHaveBeenCalledTimes(1); expect(UIManager.updateView).toHaveBeenCalledWith( expect.any(Number), @@ -247,92 +230,6 @@ describe('ReactNative', () => { }); }); - it('should be able to setNativeProps on native refs', () => { - const View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {foo: true}, - uiViewClassName: 'RCTView', - })); - - UIManager.updateView.mockReset(); - - let viewRef; - ReactNative.render( - { - viewRef = ref; - }} - />, - 11, - ); - - ReactNative.setNativeProps(viewRef, {}); - expect(UIManager.updateView).not.toBeCalled(); - - ReactNative.setNativeProps(viewRef, {foo: 'baz'}); - expect(UIManager.updateView).toHaveBeenCalledTimes(1); - expect(UIManager.updateView).toHaveBeenCalledWith( - expect.any(Number), - 'RCTView', - {foo: 'baz'}, - ); - }); - - it('should warn and no-op if calling setNativeProps on non native refs', () => { - const View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {foo: true}, - uiViewClassName: 'RCTView', - })); - - class BasicClass extends React.Component { - render() { - return ; - } - } - - class Subclass extends ReactNative.NativeComponent { - render() { - return ; - } - } - - const CreateClass = createReactClass({ - mixins: [NativeMethodsMixin], - render: () => { - return ; - }, - }); - - [BasicClass, Subclass, CreateClass].forEach(Component => { - UIManager.updateView.mockReset(); - - let viewRef; - ReactNative.render( - { - viewRef = ref; - }} - />, - 11, - ); - - expect(UIManager.updateView).not.toBeCalled(); - expect(() => { - ReactNative.setNativeProps(viewRef, {foo: 'baz'}); - }).toWarnDev( - [ - "Warning: setNativeProps was called with a ref that isn't a " + - 'native component. Use React.forwardRef to get access ' + - 'to the underlying native component', - ], - {withoutStack: true}, - ); - - expect(UIManager.updateView).not.toBeCalled(); - }); - }); - it('should call UIManager.measure on ref.measure', () => { const View = createReactNativeComponentClass('RCTView', () => ({ validAttributes: {foo: true}, diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 99720c713d43e..c1645f0497674 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -56,10 +56,6 @@ export const enableStableConcurrentModeAPIs = false; export const warnAboutShorthandPropertyCollision = false; -// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information -// This is a flag so we can fix warnings in RN core before turning it on -export const warnAboutDeprecatedSetNativeProps = false; - // Experimental React Flare event system and event components support. export const enableFlareAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 3a424a2760ea4..071b21ce6f0c0 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -31,7 +31,6 @@ export const disableJavaScriptURLs = false; export const disableInputAttributeSyncing = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const warnAboutDeprecatedLifecycles = true; -export const warnAboutDeprecatedSetNativeProps = true; export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableScopeAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index cab07df14f839..a75ad028ab07f 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -26,7 +26,6 @@ export const disableInputAttributeSyncing = false; export const enableStableConcurrentModeAPIs = false; export const warnAboutShorthandPropertyCollision = false; export const enableSchedulerDebugging = false; -export const warnAboutDeprecatedSetNativeProps = false; export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableScopeAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.persistent.js b/packages/shared/forks/ReactFeatureFlags.persistent.js index 06fb43f3b74e4..cbcd3079594ef 100644 --- a/packages/shared/forks/ReactFeatureFlags.persistent.js +++ b/packages/shared/forks/ReactFeatureFlags.persistent.js @@ -26,7 +26,6 @@ export const disableInputAttributeSyncing = false; export const enableStableConcurrentModeAPIs = false; export const warnAboutShorthandPropertyCollision = false; export const enableSchedulerDebugging = false; -export const warnAboutDeprecatedSetNativeProps = false; export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableScopeAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 014a5767a2792..2e0d7a98be69c 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -26,7 +26,6 @@ export const disableInputAttributeSyncing = false; export const enableStableConcurrentModeAPIs = false; export const warnAboutShorthandPropertyCollision = false; export const enableSchedulerDebugging = false; -export const warnAboutDeprecatedSetNativeProps = false; export const enableFlareAPI = false; export const enableFundamentalAPI = false; export const enableScopeAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 03f9179dc320a..e89cd65f7caab 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -23,7 +23,6 @@ export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; export const enableStableConcurrentModeAPIs = false; export const enableSchedulerDebugging = false; -export const warnAboutDeprecatedSetNativeProps = false; export const disableJavaScriptURLs = false; export const enableFlareAPI = true; export const enableFundamentalAPI = false; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index b2800bc4f8987..0dbf7c2c8595e 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -34,7 +34,6 @@ export const enableSchedulerDebugging = true; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false; export const warnAboutDeprecatedLifecycles = true; export const warnAboutShorthandPropertyCollision = false; -export const warnAboutDeprecatedSetNativeProps = false; export const disableLegacyContext = false; export const warnAboutStringRefs = false; export const warnAboutDefaultPropsOnFunctionComponents = false;