@@ -3120,6 +3120,44 @@ describe('ReactSuspenseList', () => {
31203120 } ,
31213121 ) ;
31223122
3123+ // @gate enableSuspenseList && enableAsyncIterableChildren
3124+ it ( 'warns for async generator components in "forwards" order' , async ( ) => {
3125+ async function * Generator ( ) {
3126+ yield 'A' ;
3127+ yield 'B' ;
3128+ }
3129+ function Foo ( ) {
3130+ return (
3131+ < SuspenseList revealOrder = "forwards" >
3132+ < Generator />
3133+ </ SuspenseList >
3134+ ) ;
3135+ }
3136+
3137+ await act ( ( ) => {
3138+ React . startTransition ( ( ) => {
3139+ ReactNoop . render ( < Foo /> ) ;
3140+ } ) ;
3141+ } ) ;
3142+ assertConsoleErrorDev ( [
3143+ 'A generator Component was passed to a <SuspenseList revealOrder="forwards" />. ' +
3144+ 'This is not supported as a way to generate lists. Instead, pass an ' +
3145+ 'iterable as the children.' +
3146+ '\n in SuspenseList (at **)' +
3147+ '\n in Foo (at **)' ,
3148+ '<Generator> is an async Client Component. ' +
3149+ 'Only Server Components can be async at the moment. ' +
3150+ "This error is often caused by accidentally adding `'use client'` " +
3151+ 'to a module that was originally written for the server.\n' +
3152+ ' in Foo (at **)' ,
3153+ // We get this warning because the generator's promise themselves are not cached.
3154+ 'A component was suspended by an uncached promise. ' +
3155+ 'Creating promises inside a Client Component or hook is not yet supported, ' +
3156+ 'except via a Suspense-compatible library or framework.\n' +
3157+ ' in Foo (at **)' ,
3158+ ] ) ;
3159+ } ) ;
3160+
31233161 // @gate enableSuspenseList && enableAsyncIterableChildren
31243162 it ( 'can display async iterable in "forwards" order' , async ( ) => {
31253163 const A = createAsyncText ( 'A' ) ;
0 commit comments