Skip to content

Commit

Permalink
deprecated method renderToStaticNodeStream
Browse files Browse the repository at this point in the history
  • Loading branch information
Angrigo committed Apr 27, 2024
1 parent c238aa8 commit 4a3bdfa
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions packages/integrations/react/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a3bdfa

Please sign in to comment.