Skip to content

Commit

Permalink
Use string concat in renderToString
Browse files Browse the repository at this point in the history
I think this might be faster. We could probably use a combination of this
technique in the stream too to lower the overhead.
  • Loading branch information
sebmarkbage committed Apr 26, 2021
1 parent c07c626 commit 400286f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function renderToString(
): string {
let didFatal = false;
let fatalError = null;
const result = [];
const result = '';
const destination = {
push(chunk) {
if (chunk) {
result.push(chunk);
if (chunk !== null) {
result += chunk;
}
return true;
},
Expand All @@ -69,7 +69,7 @@ function renderToString(
if (didFatal) {
throw fatalError;
}
return result.join('');
return result;
}

function renderToNodeStream() {
Expand Down

0 comments on commit 400286f

Please sign in to comment.