React Router v7 has been released. View the docs
useAsyncError

useAsyncError

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

import { Await, useAsyncError } from "@remix-run/react";

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