From 30fcaa9b7537e521fcf2f6051322b19c8e59a7e3 Mon Sep 17 00:00:00 2001 From: sebastien Date: Mon, 7 Oct 2024 14:20:00 +0200 Subject: [PATCH] empty --- .../docusaurus/src/client/renderToHtml.tsx | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/packages/docusaurus/src/client/renderToHtml.tsx b/packages/docusaurus/src/client/renderToHtml.tsx index f3dd095f8158..b9131581b05f 100644 --- a/packages/docusaurus/src/client/renderToHtml.tsx +++ b/packages/docusaurus/src/client/renderToHtml.tsx @@ -6,32 +6,11 @@ */ import type {ReactNode} from 'react'; -// @ts-expect-error: see https://github.com/facebook/react/issues/31134 -import {renderToReadableStream as renderToReadableStreamImpl} from 'react-dom/server.browser'; -import { - renderToString, - type renderToReadableStream as renderToReadableStreamType, -} from 'react-dom/server'; +import {renderToReadableStream} from 'react-dom/server.browser'; import {text} from 'stream/consumers'; -const renderToReadableStream: typeof renderToReadableStreamType = - renderToReadableStreamImpl; - export async function renderToHtml(app: ReactNode): Promise { - return new Promise((resolve, reject) => { - renderToReadableStream(app, { - onError: (error) => reject(error), - }).then(async (stream) => { - await stream.allReady; - // @ts-expect-error: it works fine - const html = await text(stream); - - // TODO remove this test - if (html !== renderToString(app)) { - throw new Error('Bad'); - } - - resolve(html); - }, reject); - }); + const stream = await renderToReadableStream(app); + await stream.allReady; + return text(stream); }