File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
packages/react/src/__tests__ Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -868,6 +868,26 @@ describe('ReactChildren', () => {
868
868
] ) ;
869
869
} ) ;
870
870
871
+ it ( 'should warn for flattened children lists' , async ( ) => {
872
+ function ComponentRenderingFlattenedChildren ( { children} ) {
873
+ return < div > { React . Children . toArray ( children ) } </ div > ;
874
+ }
875
+
876
+ const container = document . createElement ( 'div' ) ;
877
+ const root = ReactDOMClient . createRoot ( container ) ;
878
+ await expect ( async ( ) => {
879
+ await act ( ( ) => {
880
+ root . render (
881
+ < ComponentRenderingFlattenedChildren >
882
+ { [ < div /> ] }
883
+ </ ComponentRenderingFlattenedChildren > ,
884
+ ) ;
885
+ } ) ;
886
+ } ) . toErrorDev ( [
887
+ 'Warning: Each child in a list should have a unique "key" prop.' ,
888
+ ] ) ;
889
+ } ) ;
890
+
871
891
it ( 'does not warn for flattened positional children' , async ( ) => {
872
892
function ComponentRenderingFlattenedChildren ( { children} ) {
873
893
return < div > { React . Children . toArray ( children ) } </ div > ;
You can’t perform that action at this time.
0 commit comments