Skip to content

Commit

Permalink
Use defer in child loader
Browse files Browse the repository at this point in the history
  • Loading branch information
steinybot committed Mar 2, 2024
1 parent 864d796 commit 7df4b5d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/data-router/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,10 @@ function RenderAwaitedError() {
}

export async function childLoader({ routeLoaderData }: LoaderFunctionArgs) {
const data = await routeLoaderData("deferred")! as DeferredRouteLoaderData
return data.lazy2.then((message) => "Child: " + message)
const dataPromise = routeLoaderData("deferred")! as Promise<DeferredRouteLoaderData>
return defer({
lazy2: dataPromise.then(data => data.lazy2.then((message) => "Child: " + message))
})
}

export function DeferredChild(): React.ReactElement {
Expand Down

0 comments on commit 7df4b5d

Please sign in to comment.