@@ -46,13 +46,15 @@ import {
4646import { StrictMode } from './ReactTypeOfMode' ;
4747
4848let didWarnAboutMaps ;
49+ let didWarnAboutGenerators ;
4950let didWarnAboutStringRefInStrictMode ;
5051let ownerHasKeyUseWarning ;
5152let ownerHasFunctionTypeWarning ;
5253let warnForMissingKey = ( child : mixed ) => { } ;
5354
5455if ( __DEV__ ) {
5556 didWarnAboutMaps = false ;
57+ didWarnAboutGenerators = false ;
5658 didWarnAboutStringRefInStrictMode = { } ;
5759
5860 /**
@@ -903,6 +905,22 @@ function ChildReconciler(shouldTrackSideEffects) {
903905 ) ;
904906
905907 if ( __DEV__ ) {
908+ // We don't support rendering Generators because it's a mutation.
909+ // See https://github.com/facebook/react/issues/12995
910+ if (
911+ typeof Symbol === 'function' &&
912+ newChildrenIterable [ Symbol . toStringTag ] === 'Generator'
913+ ) {
914+ warning (
915+ didWarnAboutGenerators ,
916+ 'Using Generators as children is unsupported and will likely yield ' +
917+ 'unexpected results because enumerating a generator mutates it. ' +
918+ 'You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind ' +
919+ 'you might need to polyfill these features for older browsers.' ,
920+ ) ;
921+ didWarnAboutGenerators = true ;
922+ }
923+
906924 // Warn about using Maps as children
907925 if ( ( newChildrenIterable : any ) . entries === iteratorFn ) {
908926 warning (
0 commit comments