@@ -13,8 +13,6 @@ let React;
13
13
let ReactDOM ;
14
14
let ReactTestUtils ;
15
15
16
- let ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
17
-
18
16
// NOTE: We're explicitly not using JSX here. This is intended to test
19
17
// a new React.jsx api which does not have a JSX transformer yet.
20
18
// A lot of these tests are pulled from ReactElement-test because
@@ -30,9 +28,6 @@ describe('ReactElement.jsx', () => {
30
28
originalSymbol = global . Symbol ;
31
29
global . Symbol = undefined ;
32
30
33
- ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
34
- ReactFeatureFlags . warnAboutSpreadingKeyToJSX = true ;
35
-
36
31
React = require ( 'react' ) ;
37
32
ReactDOM = require ( 'react-dom' ) ;
38
33
ReactTestUtils = require ( 'react-dom/test-utils' ) ;
@@ -356,26 +351,30 @@ describe('ReactElement.jsx', () => {
356
351
) ;
357
352
} ) ;
358
353
359
- it ( 'should warn when keys are passed as part of props' , ( ) => {
360
- const container = document . createElement ( 'div' ) ;
361
- class Child extends React . Component {
362
- render ( ) {
363
- return React . jsx ( 'div' , { } ) ;
354
+ if ( require ( 'shared/ReactFeatureFlags' ) . warnAboutSpreadingKeyToJSX ) {
355
+ it ( 'should warn when keys are passed as part of props' , ( ) => {
356
+ const container = document . createElement ( 'div' ) ;
357
+ class Child extends React . Component {
358
+ render ( ) {
359
+ return React . jsx ( 'div' , { } ) ;
360
+ }
364
361
}
365
- }
366
- class Parent extends React . Component {
367
- render ( ) {
368
- return React . jsx ( 'div' , {
369
- children : [ React . jsx ( Child , { key : '0' } ) ] ,
370
- } ) ;
362
+ class Parent extends React . Component {
363
+ render ( ) {
364
+ return React . jsx ( 'div' , {
365
+ children : [ React . jsx ( Child , { key : '0' } ) ] ,
366
+ } ) ;
367
+ }
371
368
}
372
- }
373
- expect ( ( ) => ReactDOM . render ( React . jsx ( Parent , { } ) , container ) ) . toErrorDev (
374
- 'Warning: React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
375
- 'Explicitly pass a key after spreading props in your JSX call. ' +
376
- 'E.g. <Child {...props} key={key} />' ,
377
- ) ;
378
- } ) ;
369
+ expect ( ( ) =>
370
+ ReactDOM . render ( React . jsx ( Parent , { } ) , container ) ,
371
+ ) . toErrorDev (
372
+ 'Warning: React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
373
+ 'Explicitly pass a key after spreading props in your JSX call. ' +
374
+ 'E.g. <Child {...props} key={key} />' ,
375
+ ) ;
376
+ } ) ;
377
+ }
379
378
380
379
it ( 'should not warn when unkeyed children are passed to jsxs' , ( ) => {
381
380
const container = document . createElement ( 'div' ) ;
0 commit comments