diff --git a/.changeset/twelve-bulldogs-raise.md b/.changeset/twelve-bulldogs-raise.md new file mode 100644 index 000000000000..d0acf5c09429 --- /dev/null +++ b/.changeset/twelve-bulldogs-raise.md @@ -0,0 +1,5 @@ +--- +"@astrojs/react": patch +--- + +Removes using deprecated `ReactDOMServer.renderToStaticNodeStream` API diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index b2e94fbf0b6e..2ff3f55fb25b 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -106,18 +106,10 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl identifierPrefix: prefix, }; let html; - if (metadata?.hydrate) { - if ('renderToReadableStream' in ReactDOM) { - html = await renderToReadableStreamAsync(vnode, renderOptions); - } else { - html = await renderToPipeableStreamAsync(vnode, renderOptions); - } + if ('renderToReadableStream' in ReactDOM) { + html = await renderToReadableStreamAsync(vnode, renderOptions); } else { - if ('renderToReadableStream' in ReactDOM) { - html = await renderToReadableStreamAsync(vnode, renderOptions); - } else { - html = await renderToStaticNodeStreamAsync(vnode, renderOptions); - } + html = await renderToPipeableStreamAsync(vnode, renderOptions); } return { html, attrs }; } @@ -150,28 +142,6 @@ async function renderToPipeableStreamAsync(vnode, options) { }); } -async function renderToStaticNodeStreamAsync(vnode, options) { - const Writable = await getNodeWritable(); - let html = ''; - return new Promise((resolve, reject) => { - let stream = ReactDOM.renderToStaticNodeStream(vnode, options); - stream.on('error', (err) => { - reject(err); - }); - stream.pipe( - new Writable({ - write(chunk, _encoding, callback) { - html += chunk.toString('utf-8'); - callback(); - }, - destroy() { - resolve(html); - }, - }) - ); - }); -} - /** * Use a while loop instead of "for await" due to cloudflare and Vercel Edge issues * See https://github.com/facebook/react/issues/24169