@@ -20,11 +20,8 @@ let FabricUIManager;
20
20
let StrictMode ;
21
21
let NativeMethodsMixin ;
22
22
23
- const SET_NATIVE_PROPS_DEPRECATION_MESSAGE =
24
- 'Warning: Calling ref.setNativeProps(nativeProps) ' +
25
- 'is deprecated and will be removed in a future release. ' +
26
- 'Use the setNativeProps export from the react-native package instead.' +
27
- "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" ;
23
+ const SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE =
24
+ 'Warning: setNativeProps is not currently supported in Fabric' ;
28
25
29
26
jest . mock ( 'shared/ReactFeatureFlags' , ( ) =>
30
27
require ( 'shared/forks/ReactFeatureFlags.native-oss' ) ,
@@ -176,7 +173,7 @@ describe('ReactFabric', () => {
176
173
expect ( FabricUIManager . __dumpHierarchyForJestTestsOnly ( ) ) . toMatchSnapshot ( ) ;
177
174
} ) ;
178
175
179
- it ( 'should not call UIManager.updateView from ref.setNativeProps for properties that have not changed ' , ( ) => {
176
+ it ( 'should not call UIManager.updateView from ref.setNativeProps' , ( ) => {
180
177
const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
181
178
validAttributes : { foo : true } ,
182
179
uiViewClassName : 'RCTView' ,
@@ -212,27 +209,22 @@ describe('ReactFabric', () => {
212
209
213
210
expect ( ( ) => {
214
211
viewRef . setNativeProps ( { } ) ;
215
- } ) . toWarnDev ( [ SET_NATIVE_PROPS_DEPRECATION_MESSAGE ] , {
212
+ } ) . toWarnDev ( [ SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE ] , {
216
213
withoutStack : true ,
217
214
} ) ;
218
215
219
216
expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
220
217
221
218
expect ( ( ) => {
222
219
viewRef . setNativeProps ( { foo : 'baz' } ) ;
223
- } ) . toWarnDev ( [ SET_NATIVE_PROPS_DEPRECATION_MESSAGE ] , {
220
+ } ) . toWarnDev ( [ SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE ] , {
224
221
withoutStack : true ,
225
222
} ) ;
226
- expect ( UIManager . updateView ) . toHaveBeenCalledTimes ( 1 ) ;
227
- expect ( UIManager . updateView ) . toHaveBeenCalledWith (
228
- expect . any ( Number ) ,
229
- 'RCTView' ,
230
- { foo : 'baz' } ,
231
- ) ;
223
+ expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
232
224
} ) ;
233
225
} ) ;
234
226
235
- it ( 'should be able to setNativeProps on native refs' , ( ) => {
227
+ it ( 'setNativeProps on native refs should no-op ' , ( ) => {
236
228
const View = createReactNativeComponentClass ( 'RCTView' , ( ) => ( {
237
229
validAttributes : { foo : true } ,
238
230
uiViewClassName : 'RCTView' ,
@@ -252,13 +244,12 @@ describe('ReactFabric', () => {
252
244
) ;
253
245
254
246
expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
255
- ReactFabric . setNativeProps ( viewRef , { foo : 'baz' } ) ;
256
- expect ( UIManager . updateView ) . toHaveBeenCalledTimes ( 1 ) ;
257
- expect ( UIManager . updateView ) . toHaveBeenCalledWith (
258
- expect . any ( Number ) ,
259
- 'RCTView' ,
260
- { foo : 'baz' } ,
261
- ) ;
247
+ expect ( ( ) => {
248
+ ReactFabric . setNativeProps ( viewRef , { foo : 'baz' } ) ;
249
+ } ) . toWarnDev ( [ SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE ] , {
250
+ withoutStack : true ,
251
+ } ) ;
252
+ expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
262
253
} ) ;
263
254
264
255
it ( 'should warn and no-op if calling setNativeProps on non native refs' , ( ) => {
@@ -303,14 +294,9 @@ describe('ReactFabric', () => {
303
294
expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
304
295
expect ( ( ) => {
305
296
ReactFabric . setNativeProps ( viewRef , { foo : 'baz' } ) ;
306
- } ) . toWarnDev (
307
- [
308
- "Warning: setNativeProps was called with a ref that isn't a " +
309
- 'native component. Use React.forwardRef to get access ' +
310
- 'to the underlying native component' ,
311
- ] ,
312
- { withoutStack : true } ,
313
- ) ;
297
+ } ) . toWarnDev ( [ SET_NATIVE_PROPS_NOT_SUPPORTED_MESSAGE ] , {
298
+ withoutStack : true ,
299
+ } ) ;
314
300
315
301
expect ( UIManager . updateView ) . not . toBeCalled ( ) ;
316
302
} ) ;
0 commit comments