ErrorAlertFallback

The ErrorAlertFallback is a simple component used to render any error in a MUI Alert component. It can be used with the react-error-boundary package, or by simply passing any error to the error property.

Usage

With react-error-boundary:

import { ErrorBoundary } from "react-error-boundary";
import { ErrorAlertFallback } from "@olenbetong/appframe-mui";

function MyComponent() {
  return (
    <ErrorBoundary FallbackComponent={ErrorAlertFallback} key={periodType}>
      <SomeComponentThatCanThrowAnError />
    </ErrorBoundary>
  );
}

With any error message:

import { useError } from "@olenbetong/appframe-react";
import { ErrorAlertFallback } from "@olenbetong/appframe-mui";

function DataObjectError() {
  let error = useError(dsMyDataObject);

  return error ? <ErrorAlertFallback error={error} /> : null;
}

Last updated

Was this helpful?