awaitOptions
⚠️
<Await/> is experimental feature, this interfaces could be changed
awaitOptions combines a key and a function to help manage the options in the current <Await /> component.
import { Await, awaitOptions } from '@suspensive/react-await'
import { Suspense } from '@suspensive/react'
 
const getPost = (postId: number) => fetch(`/post/${postId}`).then<Post>((res) => res.json())
 
const postAwaitOptions = awaitOptions({ key: ['post', 2] as const, fn: ({ key: [, postId] }) => getPost(postId) })
 
const Example = () => (
  <Suspense fallback="awaiting...">
    <Await options={postAwaitOptions}>
      {(awaited) => <>{awaited.data}</>} // Post
    </Await>
  </Suspense>
)