How to use the react-error-boundary.useErrorHandler function in react-error-boundary

To help you get started, we’ve selected a few react-error-boundary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exercism / website / app / javascript / components / ErrorBoundary.tsx View on Github external
export const useErrorHandler = (
  error: unknown,
  { defaultError }: { defaultError: Error }
): void => {
  const handler = useReactErrorHandler()

  useEffect(() => {
    if (!error) {
      return
    }

    if (error instanceof Error) {
      Bugsnag.notify(error)

      handler(new HandledError(defaultError.message))
    } else if (error instanceof Response) {
      error
        .clone()
        .json()
        .then((res: { error: APIError }) => {
          handler(new HandledError(res.error.message))

react-error-boundary

Simple reusable React error boundary component

MIT
Latest version published 16 days ago

Package Health Score

97 / 100
Full package analysis

Similar packages