From 400286fea8215544d8fa979c89a8d9e3bcc2fd51 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 19 Apr 2021 12:42:38 -0400 Subject: [PATCH] Use string concat in renderToString I think this might be faster. We could probably use a combination of this technique in the stream too to lower the overhead. --- .../react-dom/src/server/ReactDOMLegacyServerBrowser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js b/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js index 2ea0b22d10abc..e70bcacadc8db 100644 --- a/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js @@ -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; }, @@ -69,7 +69,7 @@ function renderToString( if (didFatal) { throw fatalError; } - return result.join(''); + return result; } function renderToNodeStream() {