@@ -21,7 +21,6 @@ import {
2121 REACT_FRAGMENT_TYPE ,
2222 REACT_ELEMENT_TYPE ,
2323} from 'shared/ReactSymbols' ;
24- import { warnAboutSpreadingKeyToJSX } from 'shared/ReactFeatureFlags' ;
2524import checkPropTypes from 'shared/checkPropTypes' ;
2625import isArray from 'shared/isArray' ;
2726
@@ -365,45 +364,41 @@ export function jsxWithValidation(
365364 Object . freeze ( children ) ;
366365 }
367366 } 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+ ) ;
375372 }
376373 } else {
377374 validateChildKeys ( children , type ) ;
378375 }
379376 }
380377 }
381378
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 ;
407402 }
408403 }
409404
0 commit comments