mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 16:29:47 +02:00
fix(core): make error boundary fallback a component instead of a callback (#7368)
This commit is contained in:
parent
77fa3d1470
commit
f29bb73300
3 changed files with 20 additions and 18 deletions
|
@ -33,17 +33,13 @@ export default class ErrorBoundary extends React.Component<Props, State> {
|
|||
const {error} = this.state;
|
||||
|
||||
if (error) {
|
||||
const fallback = this.props.fallback ?? DefaultFallback;
|
||||
return fallback({
|
||||
error,
|
||||
tryAgain: () => this.setState({error: null}),
|
||||
});
|
||||
const Fallback = this.props.fallback ?? DefaultFallback;
|
||||
return (
|
||||
<Fallback error={error} tryAgain={() => this.setState({error: null})} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
children ??
|
||||
// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
|
||||
null
|
||||
);
|
||||
// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
|
||||
return children ?? null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue