From 2ad6f4635615854f40bacb2dbe260e94a0fe1292 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Wed, 25 May 2022 18:53:25 +0800 Subject: [PATCH] fix(core): always treat error boundary fallback as a callback --- packages/docusaurus-module-type-aliases/src/index.d.ts | 10 +++++----- .../src/theme/Layout/index.tsx | 4 +++- packages/docusaurus/src/client/App.tsx | 4 +--- .../docusaurus/src/client/exports/ErrorBoundary.tsx | 10 ++++++---- website/docs/docusaurus-core.md | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/docusaurus-module-type-aliases/src/index.d.ts b/packages/docusaurus-module-type-aliases/src/index.d.ts index 3a900c907d77..243c06c9c4ed 100644 --- a/packages/docusaurus-module-type-aliases/src/index.d.ts +++ b/packages/docusaurus-module-type-aliases/src/index.d.ts @@ -80,9 +80,9 @@ declare module '@theme/Error' { import type {ComponentProps} from 'react'; import type ErrorBoundary from '@docusaurus/ErrorBoundary'; - type ErrorProps = ComponentProps< + type ErrorProps = Parameters< NonNullable['fallback']> - >; + >[0]; export interface Props extends ErrorProps {} export default function Error(props: Props): JSX.Element; @@ -125,13 +125,13 @@ declare module '@docusaurus/constants' { } declare module '@docusaurus/ErrorBoundary' { - import type {ReactNode, ComponentType} from 'react'; + import type {ReactNode} from 'react'; export interface Props { - readonly fallback?: ComponentType<{ + readonly fallback?: (props: { readonly error: Error; readonly tryAgain: () => void; - }>; + }) => JSX.Element; readonly children: ReactNode; } export default function ErrorBoundary(props: Props): JSX.Element; diff --git a/packages/docusaurus-theme-classic/src/theme/Layout/index.tsx b/packages/docusaurus-theme-classic/src/theme/Layout/index.tsx index c5503edcaaa2..f6e749c9833d 100644 --- a/packages/docusaurus-theme-classic/src/theme/Layout/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/Layout/index.tsx @@ -45,7 +45,9 @@ export default function Layout(props: Props): JSX.Element {
- {children} + }> + {children} +
{!noFooter &&