@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
28 lines (27 loc) • 1.11 kB
TypeScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import { type ErrorInfo, type JSX, type ReactNode } from 'react';
/**
* Props for the {@link LexicalErrorBoundary} component.
*/
export type LexicalErrorBoundaryProps = {
children: JSX.Element;
fallback?: ReactNode;
onError: (error: Error, info: ErrorInfo) => void;
};
/**
* An error boundary used by {@link RichTextPlugin} and {@link PlainTextPlugin}
* to isolate failures thrown while rendering decorator nodes. It renders
* `fallback` in place of the failed subtree and forwards the error (coerced to
* an `Error`) along with the React {@link ErrorInfo} to the `onError` callback.
* When `fallback` is omitted a small default message is shown; pass
* `fallback={null}` to render nothing.
*
* @returns The wrapped `children`, or the fallback if an error is caught.
*/
export declare function LexicalErrorBoundary({ children, fallback, onError, }: LexicalErrorBoundaryProps): JSX.Element;