(props: {
fallback?: (error: NotFoundError) => Solid.JSX.Element
onCatch?: (error: Error) => void
children: Solid.JSX.Element
})
| 5 | import type { NotFoundError } from '@tanstack/router-core' |
| 6 | |
| 7 | export function CatchNotFound(props: { |
| 8 | fallback?: (error: NotFoundError) => Solid.JSX.Element |
| 9 | onCatch?: (error: Error) => void |
| 10 | children: Solid.JSX.Element |
| 11 | }) { |
| 12 | // TODO: Some way for the user to programmatically reset the not-found boundary? |
| 13 | const resetKey = useRouterState({ |
| 14 | select: (s) => `not-found-${s.location.pathname}-${s.status}`, |
| 15 | }) |
| 16 | |
| 17 | return ( |
| 18 | <CatchBoundary |
| 19 | getResetKey={() => resetKey()} |
| 20 | onCatch={(error) => { |
| 21 | if (isNotFound(error)) { |
| 22 | props.onCatch?.(error) |
| 23 | } else { |
| 24 | throw error |
| 25 | } |
| 26 | }} |
| 27 | errorComponent={({ error }) => { |
| 28 | if (isNotFound(error)) { |
| 29 | return props.fallback?.(error) |
| 30 | } else { |
| 31 | throw error |
| 32 | } |
| 33 | }} |
| 34 | > |
| 35 | {props.children} |
| 36 | </CatchBoundary> |
| 37 | ) |
| 38 | } |
| 39 | |
| 40 | export function DefaultGlobalNotFound() { |
| 41 | return <p>Not Found</p> |
nothing calls this directly
no test coverage detected