The Await component is a component that suspends until the provided promise is resolved or rejected. This is only necessary for React 18. If you are using React 19, you can use the use() hook instead.
The Await component accepts the following props:
import { Await } from '@tanstack/react-router'
function Component() {
const { deferredPromise } = route.useLoaderData()
return (
<Await promise={deferredPromise}>
{(data) => <div>{JSON.stringify(data)}</div>}
</Await>
)
}
import { Await } from '@tanstack/react-router'
function Component() {
const { deferredPromise } = route.useLoaderData()
return (
<Await promise={deferredPromise}>
{(data) => <div>{JSON.stringify(data)}</div>}
</Await>
)
}
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.