@@ -13,8 +13,6 @@ let React;
1313let ReactDOM ;
1414let ReactTestUtils ;
1515
16- let ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
17-
1816// NOTE: We're explicitly not using JSX here. This is intended to test
1917// a new React.jsx api which does not have a JSX transformer yet.
2018// A lot of these tests are pulled from ReactElement-test because
@@ -30,9 +28,6 @@ describe('ReactElement.jsx', () => {
3028 originalSymbol = global . Symbol ;
3129 global . Symbol = undefined ;
3230
33- ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
34- ReactFeatureFlags . warnAboutSpreadingKeyToJSX = true ;
35-
3631 React = require ( 'react' ) ;
3732 ReactDOM = require ( 'react-dom' ) ;
3833 ReactTestUtils = require ( 'react-dom/test-utils' ) ;
@@ -356,26 +351,30 @@ describe('ReactElement.jsx', () => {
356351 ) ;
357352 } ) ;
358353
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+ }
364361 }
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+ }
371368 }
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+ }
379378
380379 it ( 'should not warn when unkeyed children are passed to jsxs' , ( ) => {
381380 const container = document . createElement ( 'div' ) ;
0 commit comments