useAsyncError

useAsyncError

概述

参考文档 ↗

返回最近的 Await 组件的拒绝值。

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

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

// somewhere in your app
<Await
  resolve={promiseThatRejects}
  errorElement={<ErrorElement />}
/>;

签名

useAsyncError(): unknown
文档和示例 CC 4.0