diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js index 07654a9f13c0a..ec962ef8ba52c 100644 --- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js @@ -609,6 +609,41 @@ describe('ReactDOMServer', () => { expect(response.read()).toBeNull(); }); }); + + it('should refer users to new apis when using suspense', async () => { + let resolve = null; + const promise = new Promise(res => { + resolve = () => { + resolved = true; + res(); + }; + }); + let resolved = false; + function Suspender() { + if (resolved) { + return 'resolved'; + } + throw promise; + } + + let response; + expect(() => { + response = ReactDOMServer.renderToNodeStream( +
+ + + +
, + ); + }).toErrorDev( + 'renderToNodeStream is deprecated. Use renderToPipeableStream instead.', + {withoutStack: true}, + ); + await resolve(); + expect(response.read().toString()).toEqual( + '
resolved
', + ); + }); }); describe('renderToStaticNodeStream', () => { @@ -632,7 +667,7 @@ describe('ReactDOMServer', () => { }); }); - it('should refer users to new apis when using suspense', async () => { + it('should omit text and suspense placeholders', async () => { let resolve = null; const promise = new Promise(res => { resolve = () => { @@ -648,23 +683,15 @@ describe('ReactDOMServer', () => { throw promise; } - let response; - expect(() => { - response = ReactDOMServer.renderToNodeStream( -
- - - -
, - ); - }).toErrorDev( - 'renderToNodeStream is deprecated. Use renderToPipeableStream instead.', - {withoutStack: true}, + const response = ReactDOMServer.renderToStaticNodeStream( +
+ + + +
, ); await resolve(); - expect(response.read().toString()).toEqual( - '
resolved
', - ); + expect(response.read().toString()).toEqual('
resolved
'); }); }); diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js b/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js index 8df44d8004261..16090d9035668 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js @@ -78,7 +78,7 @@ function renderToNodeStreamImpl( const request = createRequest( children, resumableState, - createRenderState(resumableState, false), + createRenderState(resumableState, generateStaticMarkup), createRootFormatContext(), Infinity, onError,