main
Branches
main (6.22.3)dev
Versions
6.22.3v4/5.xv3.x
useAsyncValue

useAsyncValue

Returns the resolved data from the nearest <Await> ancestor component.

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

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

See the Deferred Data Guide and <Await> docs for more information.

Docs and examples CC 4.0
Edit