react-error-boundary

  • Version 5.0.0
  • Published
  • 32.6 kB
  • 1 dependency
  • MIT license

Install

npm i react-error-boundary
yarn add react-error-boundary
pnpm add react-error-boundary

Overview

Simple reusable React error boundary component

Index

Variables

variable ErrorBoundaryContext

const ErrorBoundaryContext: any;

    Functions

    function useErrorBoundary

    useErrorBoundary: <TError = any>() => UseErrorBoundaryApi<TError>;

      function withErrorBoundary

      withErrorBoundary: <T extends ComponentType<any>>(
      component: T,
      errorBoundaryProps: ErrorBoundaryProps
      ) => ForwardRefExoticComponent<any>;

        Classes

        class ErrorBoundary

        class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {}

          constructor

          constructor(props: any);

            method componentDidCatch

            componentDidCatch: (error: Error, info: ErrorInfo) => void;

              method componentDidUpdate

              componentDidUpdate: (
              prevProps: ErrorBoundaryProps,
              prevState: ErrorBoundaryState
              ) => void;

                method getDerivedStateFromError

                static getDerivedStateFromError: (error: Error) => {
                didCatch: boolean;
                error: Error;
                };

                  method render

                  render: () => any;

                    method resetErrorBoundary

                    resetErrorBoundary: (...args: any[]) => void;

                      Type Aliases

                      type ErrorBoundaryContextType

                      type ErrorBoundaryContextType = {
                      didCatch: boolean;
                      error: any;
                      resetErrorBoundary: (...args: any[]) => void;
                      };

                        type ErrorBoundaryProps

                        type ErrorBoundaryProps =
                        | ErrorBoundaryPropsWithFallback
                        | ErrorBoundaryPropsWithComponent
                        | ErrorBoundaryPropsWithRender;

                          type ErrorBoundaryPropsWithComponent

                          type ErrorBoundaryPropsWithComponent = ErrorBoundarySharedProps & {
                          fallback?: never;
                          FallbackComponent: ComponentType<FallbackProps>;
                          fallbackRender?: never;
                          };

                            type ErrorBoundaryPropsWithFallback

                            type ErrorBoundaryPropsWithFallback = ErrorBoundarySharedProps & {
                            fallback: ReactNode;
                            FallbackComponent?: never;
                            fallbackRender?: never;
                            };

                              type ErrorBoundaryPropsWithRender

                              type ErrorBoundaryPropsWithRender = ErrorBoundarySharedProps & {
                              fallback?: never;
                              FallbackComponent?: never;
                              fallbackRender: (props: FallbackProps) => ReactNode;
                              };

                                type FallbackProps

                                type FallbackProps = {
                                error: any;
                                resetErrorBoundary: (...args: any[]) => void;
                                };

                                  type UseErrorBoundaryApi

                                  type UseErrorBoundaryApi<TError> = {
                                  resetBoundary: () => void;
                                  showBoundary: (error: TError) => void;
                                  };

                                    Package Files (6)

                                    Dependencies (1)

                                    Dev Dependencies (23)

                                    Peer Dependencies (1)

                                    Badge

                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/react-error-boundary.

                                    • Markdown
                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/react-error-boundary)
                                    • HTML
                                      <a href="https://www.jsdocs.io/package/react-error-boundary"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>