@@ -21,7 +21,6 @@ import {
21
21
REACT_FRAGMENT_TYPE ,
22
22
REACT_ELEMENT_TYPE ,
23
23
} from 'shared/ReactSymbols' ;
24
- import { warnAboutSpreadingKeyToJSX } from 'shared/ReactFeatureFlags' ;
25
24
import checkPropTypes from 'shared/checkPropTypes' ;
26
25
import isArray from 'shared/isArray' ;
27
26
@@ -365,45 +364,41 @@ export function jsxWithValidation(
365
364
Object . freeze ( children ) ;
366
365
}
367
366
} else {
368
- if ( __DEV__ ) {
369
- console . error (
370
- 'React.jsx: Static children should always be an array. ' +
371
- 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' +
372
- 'Use the Babel transform instead.' ,
373
- ) ;
374
- }
367
+ console . error (
368
+ 'React.jsx: Static children should always be an array. ' +
369
+ 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' +
370
+ 'Use the Babel transform instead.' ,
371
+ ) ;
375
372
}
376
373
} else {
377
374
validateChildKeys ( children , type ) ;
378
375
}
379
376
}
380
377
}
381
378
382
- if ( warnAboutSpreadingKeyToJSX ) {
383
- if ( hasOwnProperty . call ( props , 'key' ) ) {
384
- const componentName = getComponentNameFromType ( type ) ;
385
- const keys = Object . keys ( props ) . filter ( k => k !== 'key' ) ;
386
- const beforeExample =
387
- keys . length > 0
388
- ? '{key: someKey, ' + keys . join ( ': ..., ' ) + ': ...}'
389
- : '{key: someKey}' ;
390
- if ( ! didWarnAboutKeySpread [ componentName + beforeExample ] ) {
391
- const afterExample =
392
- keys . length > 0 ? '{' + keys . join ( ': ..., ' ) + ': ...}' : '{}' ;
393
- console . error (
394
- 'A props object containing a "key" prop is being spread into JSX:\n' +
395
- ' let props = %s;\n' +
396
- ' <%s {...props} />\n' +
397
- 'React keys must be passed directly to JSX without using spread:\n' +
398
- ' let props = %s;\n' +
399
- ' <%s key={someKey} {...props} />' ,
400
- beforeExample ,
401
- componentName ,
402
- afterExample ,
403
- componentName ,
404
- ) ;
405
- didWarnAboutKeySpread [ componentName + beforeExample ] = true ;
406
- }
379
+ if ( hasOwnProperty . call ( props , 'key' ) ) {
380
+ const componentName = getComponentNameFromType ( type ) ;
381
+ const keys = Object . keys ( props ) . filter ( k => k !== 'key' ) ;
382
+ const beforeExample =
383
+ keys . length > 0
384
+ ? '{key: someKey, ' + keys . join ( ': ..., ' ) + ': ...}'
385
+ : '{key: someKey}' ;
386
+ if ( ! didWarnAboutKeySpread [ componentName + beforeExample ] ) {
387
+ const afterExample =
388
+ keys . length > 0 ? '{' + keys . join ( ': ..., ' ) + ': ...}' : '{}' ;
389
+ console . error (
390
+ 'A props object containing a "key" prop is being spread into JSX:\n' +
391
+ ' let props = %s;\n' +
392
+ ' <%s {...props} />\n' +
393
+ 'React keys must be passed directly to JSX without using spread:\n' +
394
+ ' let props = %s;\n' +
395
+ ' <%s key={someKey} {...props} />' ,
396
+ beforeExample ,
397
+ componentName ,
398
+ afterExample ,
399
+ componentName ,
400
+ ) ;
401
+ didWarnAboutKeySpread [ componentName + beforeExample ] = true ;
407
402
}
408
403
}
409
404
0 commit comments