main
分支
main (6.23.1)dev
版本
6.23.1v4/5.xv3.x
useAsyncValue

useAsyncValue

傳回最近的 <Await> 祖先元件中已解析的資料。

function ProductVariants() {
  const variants = useAsyncValue();
  return <div>{/* ... */}</div>;
}

// Await creates the context for the value
<Await resolve={somePromiseForProductVariants}>
  <ProductVariants />
</Await>;

更多相關資訊請參閱 遞延資料指南<Await> 文件