fix(live-codeblock): add error boundary to live code preview (#8015)

Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
Rashid 2022-10-13 19:49:27 +04:00 committed by GitHub
parent 80064b2eb9
commit 79b3f65a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 16 deletions

View file

@ -80,3 +80,5 @@ export {usePrismTheme} from './hooks/usePrismTheme';
export {useDocsPreferredVersion} from './contexts/docsPreferredVersion';
export {processAdmonitionProps} from './utils/admonitionUtils';
export {ErrorBoundaryTryAgainButton} from './utils/errorBoundaryUtils';

View file

@ -0,0 +1,23 @@
/**
* 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, {type ComponentProps} from 'react';
import Translate from '@docusaurus/Translate';
export function ErrorBoundaryTryAgainButton(
props: ComponentProps<'button'>,
): JSX.Element {
return (
<button type="button" {...props}>
<Translate
id="theme.ErrorPageContent.tryAgain"
description="The label of the button to try again rendering when the React error boundary captures an error">
Try again
</Translate>
</button>
);
}