Skip to content

Commit 4be45be

Browse files
authored
Stop warning about setNativeProps being deprecated (#17045)
* Stop warning about setNativeProps being deprecated * Remove ReactNative.setNativeProps * Remove more Fabric tests
1 parent b71ab61 commit 4be45be

17 files changed

+3
-310
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
} from './NativeMethodsMixinUtils';
3131

3232
import warningWithoutStack from 'shared/warningWithoutStack';
33-
import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags';
3433

3534
export default function(
3635
findNodeHandle: any => ?number,
@@ -251,18 +250,6 @@ export default function(
251250
return;
252251
}
253252

254-
if (__DEV__) {
255-
if (warnAboutDeprecatedSetNativeProps) {
256-
warningWithoutStack(
257-
false,
258-
'Warning: Calling ref.setNativeProps(nativeProps) ' +
259-
'is deprecated and will be removed in a future release. ' +
260-
'Use the setNativeProps export from the react-native package instead.' +
261-
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n",
262-
);
263-
}
264-
}
265-
266253
const nativeTag =
267254
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
268255
const viewConfig: ReactNativeBaseComponentViewConfig<> =

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ const ReactFabric: ReactFabricType = {
109109

110110
findNodeHandle,
111111

112-
setNativeProps(handle: any, nativeProps: Object) {
113-
warningWithoutStack(
114-
false,
115-
'Warning: setNativeProps is not currently supported in Fabric',
116-
);
117-
118-
return;
119-
},
120-
121112
dispatchCommand(handle: any, command: string, args: Array<any>) {
122113
const invalid =
123114
handle._nativeTag == null || handle._internalInstanceHandle == null;

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {create} from './ReactNativeAttributePayload';
2727
import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
2828

2929
import warningWithoutStack from 'shared/warningWithoutStack';
30-
import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags';
3130

3231
export default function(
3332
findNodeHandle: any => ?number,
@@ -262,18 +261,6 @@ export default function(
262261
return;
263262
}
264263

265-
if (__DEV__) {
266-
if (warnAboutDeprecatedSetNativeProps) {
267-
warningWithoutStack(
268-
false,
269-
'Warning: Calling ref.setNativeProps(nativeProps) ' +
270-
'is deprecated and will be removed in a future release. ' +
271-
'Use the setNativeProps export from the react-native package instead.' +
272-
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n",
273-
);
274-
}
275-
}
276-
277264
const nativeTag =
278265
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
279266
const viewConfig: ReactNativeBaseComponentViewConfig<> =

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
} from './NativeMethodsMixinUtils';
3030

3131
import warningWithoutStack from 'shared/warningWithoutStack';
32-
import {warnAboutDeprecatedSetNativeProps} from 'shared/ReactFeatureFlags';
3332

3433
/**
3534
* This component defines the same methods as NativeMethodsMixin but without the
@@ -104,15 +103,6 @@ class ReactNativeFiberHostComponent {
104103

105104
setNativeProps(nativeProps: Object) {
106105
if (__DEV__) {
107-
if (warnAboutDeprecatedSetNativeProps) {
108-
warningWithoutStack(
109-
false,
110-
'Warning: Calling ref.setNativeProps(nativeProps) ' +
111-
'is deprecated and will be removed in a future release. ' +
112-
'Use the setNativeProps export from the react-native package instead.' +
113-
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n",
114-
);
115-
}
116106
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
117107
}
118108

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import NativeMethodsMixin from './NativeMethodsMixin';
3939
import ReactNativeComponent from './ReactNativeComponent';
4040
import {getClosestInstanceFromNode} from './ReactNativeComponentTree';
4141
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
42-
import {setNativeProps} from './ReactNativeRendererSharedExports';
4342

4443
import {LegacyRoot} from 'shared/ReactRootTags';
4544
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -133,8 +132,6 @@ const ReactNativeRenderer: ReactNativeType = {
133132
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
134133
},
135134

136-
setNativeProps,
137-
138135
render(element: React$Element<any>, containerTag: any, callback: ?Function) {
139136
let root = roots.get(containerTag);
140137

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export type ReactNativeType = {
143143
NativeComponent: typeof ReactNativeComponent,
144144
findNodeHandle(componentOrHandle: any): ?number,
145145
dispatchCommand(handle: any, command: string, args: Array<any>): void,
146-
setNativeProps(handle: any, nativeProps: Object): void,
147146
render(
148147
element: React$Element<any>,
149148
containerTag: any,
@@ -160,7 +159,6 @@ export type ReactFabricType = {
160159
NativeComponent: typeof ReactNativeComponent,
161160
findNodeHandle(componentOrHandle: any): ?number,
162161
dispatchCommand(handle: any, command: string, args: Array<any>): void,
163-
setNativeProps(handle: any, nativeProps: Object): void,
164162
render(
165163
element: React$Element<any>,
166164
containerTag: any,

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

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
let React;
1414
let ReactFabric;
15-
let ReactFeatureFlags;
1615
let createReactClass;
1716
let createReactNativeComponentClass;
1817
let UIManager;
@@ -38,8 +37,6 @@ describe('ReactFabric', () => {
3837

3938
React = require('react');
4039
StrictMode = React.StrictMode;
41-
ReactFeatureFlags = require('shared/ReactFeatureFlags');
42-
ReactFeatureFlags.warnAboutDeprecatedSetNativeProps = true;
4340
ReactFabric = require('react-native-renderer/fabric');
4441
UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
4542
.UIManager;
@@ -338,84 +335,6 @@ describe('ReactFabric', () => {
338335
});
339336
});
340337

341-
it('setNativeProps on native refs should no-op', () => {
342-
const View = createReactNativeComponentClass('RCTView', () => ({
343-
validAttributes: {foo: true},
344-
uiViewClassName: 'RCTView',
345-
}));
346-
347-
UIManager.updateView.mockReset();
348-
349-
let viewRef;
350-
ReactFabric.render(
351-
<View
352-
foo="bar"
353-
ref={ref => {
354-
viewRef = ref;
355-
}}
356-
/>,
357-
11,
358-
);
359-
360-
expect(UIManager.updateView).not.toBeCalled();
361-
expect(() => {
362-
ReactFabric.setNativeProps(viewRef, {foo: 'baz'});
363-
}).toWarnDev([SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE], {
364-
withoutStack: true,
365-
});
366-
expect(UIManager.updateView).not.toBeCalled();
367-
});
368-
369-
it('should warn and no-op if calling setNativeProps on non native refs', () => {
370-
const View = createReactNativeComponentClass('RCTView', () => ({
371-
validAttributes: {foo: true},
372-
uiViewClassName: 'RCTView',
373-
}));
374-
375-
class BasicClass extends React.Component {
376-
render() {
377-
return <React.Fragment />;
378-
}
379-
}
380-
381-
class Subclass extends ReactFabric.NativeComponent {
382-
render() {
383-
return <View />;
384-
}
385-
}
386-
387-
const CreateClass = createReactClass({
388-
mixins: [NativeMethodsMixin],
389-
render: () => {
390-
return <View />;
391-
},
392-
});
393-
394-
[BasicClass, Subclass, CreateClass].forEach(Component => {
395-
UIManager.updateView.mockReset();
396-
397-
let viewRef;
398-
ReactFabric.render(
399-
<Component
400-
foo="bar"
401-
ref={ref => {
402-
viewRef = ref;
403-
}}
404-
/>,
405-
11,
406-
);
407-
408-
expect(UIManager.updateView).not.toBeCalled();
409-
expect(() => {
410-
ReactFabric.setNativeProps(viewRef, {foo: 'baz'});
411-
}).toWarnDev([SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE], {
412-
withoutStack: true,
413-
});
414-
415-
expect(UIManager.updateView).not.toBeCalled();
416-
});
417-
});
418-
419338
it('should call FabricUIManager.measure on ref.measure', () => {
420339
const View = createReactNativeComponentClass('RCTView', () => ({
421340
validAttributes: {foo: true},

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,4 @@ describe('ReactFabric', () => {
7373
[10, 20],
7474
);
7575
});
76-
77-
it('sets native props with setNativeProps on Fabric nodes with the RN renderer', () => {
78-
UIManager.updateView.mockReset();
79-
const View = createReactNativeComponentClass('RCTView', () => ({
80-
validAttributes: {title: true},
81-
uiViewClassName: 'RCTView',
82-
}));
83-
84-
let ref = React.createRef();
85-
86-
ReactFabric.render(<View title="bar" ref={ref} />, 11);
87-
expect(UIManager.updateView).not.toBeCalled();
88-
ReactNative.setNativeProps(ref.current, {title: 'baz'});
89-
expect(UIManager.updateView).toHaveBeenCalledTimes(1);
90-
expect(UIManager.updateView).toHaveBeenCalledWith(
91-
expect.any(Number),
92-
'RCTView',
93-
{title: 'baz'},
94-
);
95-
});
9676
});

0 commit comments

Comments
 (0)