The useAwaited method is a hook that suspends until the provided promise is resolved or rejected.
The useAwaited hook accepts a single argument, an options object.
import { useAwaited } from '@tanstack/react-router'
function Component() {
const { deferredPromise } = route.useLoaderData()
const data = useAwaited({ promise: myDeferredPromise })
// ...
}
import { useAwaited } from '@tanstack/react-router'
function Component() {
const { deferredPromise } = route.useLoaderData()
const data = useAwaited({ promise: myDeferredPromise })
// ...
}
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.