From 643a7fe5a325dacfd1d809a1f40a9688e9634fa7 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 9 Oct 2023 14:28:06 +0100 Subject: [PATCH] fix(core): log missing errorInfo in React 18 onRecoverableError callback (#9387) Co-authored-by: sebastienlorber --- packages/docusaurus/src/client/clientEntry.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus/src/client/clientEntry.tsx b/packages/docusaurus/src/client/clientEntry.tsx index 175b30f3eda4..d6d4d365659e 100644 --- a/packages/docusaurus/src/client/clientEntry.tsx +++ b/packages/docusaurus/src/client/clientEntry.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import ReactDOM from 'react-dom/client'; +import ReactDOM, {type ErrorInfo} from 'react-dom/client'; import {BrowserRouter} from 'react-router-dom'; import {HelmetProvider} from 'react-helmet-async'; @@ -37,8 +37,12 @@ if (ExecutionEnvironment.canUseDOM) { ); - const onRecoverableError = (error: unknown): void => { - console.error('Docusaurus React Root onRecoverableError:', error); + const onRecoverableError = (error: unknown, errorInfo: ErrorInfo): void => { + console.error( + 'Docusaurus React Root onRecoverableError:', + error, + errorInfo, + ); }; const renderApp = () => {