useAsyncError
返回来自最近的 <Await>
组件的拒绝值。
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 />}
/>;
指南
API