import { Await, createFileRoute } from '@tanstack/react-router' import * as React from 'react' async function loadData() { await new Promise((r) => setTimeout(r, 2000)) if (Math.random() > 0.5) throw new Error('Random error in streaming!') return 'Hello!' } export const Route = createFileRoute('/error')({ component: ErrorComponent, loader: () => { if (Math.random() > 0.5) throw new Error('Random error!') return { deferredData: loadData(), } }, pendingComponent: () =>

Loading..

, wrapInSuspense: true, errorComponent: ({ error }) => { return (

Caught: {error.message}

(This page has a 75% chance of throwing an error)

) }, }) function ErrorComponent() { return (

The loader of this page will have a 75% chance of throwing an error!

{(data) =>

Streaming data loaded successfully: {data}

}
) }