Viewing docs for an older release. View latest
useAsyncError

useAsyncError

Returns the rejection value from the closest <Await> component.

import { useAsyncError, Await } from "react-router-dom";

function ErrorElement() {
  const error = useAsyncError();
  return (
    <p>Uh Oh, something went wrong! {error.message}</p>
  );
}

<Await
  resolve={promiseThatRejects}
  errorElement={<ErrorElement />}
/>;

Additional Resources

Guides

API

Docs and examples licensed under MIT