Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): error boundary should allow no children #6338

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/docusaurus-module-type-aliases/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ declare module '@theme/Layout' {
import type {ReactNode} from 'react';

export interface Props {
readonly children: ReactNode;
readonly children?: ReactNode;
readonly title?: string;
readonly description?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ declare module '@theme/Layout' {
import type {ReactNode} from 'react';

export interface Props {
readonly children: ReactNode;
readonly children?: ReactNode;
readonly title?: string;
readonly noFooter?: boolean;
readonly description?: string;
Expand Down
6 changes: 5 additions & 1 deletion packages/docusaurus/src/client/exports/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class ErrorBoundary extends React.Component<Props, State> {
});
}

return children;
return (
children ??
// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
null
);
}
}

Expand Down
14 changes: 14 additions & 0 deletions website/_dogfooding/_pages tests/layout-no-children.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import Layout from '@theme/Layout';

// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
export default function LayoutNoChildren(): JSX.Element {
return <Layout />;
}