Skip to content

Commit

Permalink
Pass the destination to startWriting instead of renderToNode
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Oct 6, 2021
1 parent 844067c commit 21db19f
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 121 deletions.
3 changes: 1 addition & 2 deletions fixtures/flight/server/handler.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ module.exports = function(req, res) {
const moduleMap = JSON.parse(data);
const {startWriting} = renderToNodePipe(
React.createElement(App),
res,
moduleMap
);
startWriting();
startWriting(res);
}
);
});
Expand Down
4 changes: 2 additions & 2 deletions fixtures/ssr/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export default function render(url, res) {
console.error('Fatal', error);
});
let didError = false;
const {startWriting, abort} = renderToNodePipe(<App assets={assets} />, res, {
const {startWriting, abort} = renderToNodePipe(<App assets={assets} />, {
onCompleteShell() {
// If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
startWriting();
startWriting(res);
},
onError(x) {
didError = true;
Expand Down
3 changes: 1 addition & 2 deletions fixtures/ssr2/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ module.exports = function render(url, res) {
<DataProvider data={data}>
<App assets={assets} />
</DataProvider>,
res,
{
onCompleteShell() {
// If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
startWriting();
startWriting(res);
},
onError(x) {
didError = true;
Expand Down
Loading

0 comments on commit 21db19f

Please sign in to comment.