MCPcopy
hub / github.com/TanStack/router / CatchNotFound

Function CatchNotFound

packages/solid-router/src/not-found.tsx:7–38  ·  view source on GitHub ↗
(props: {
  fallback?: (error: NotFoundError) => Solid.JSX.Element
  onCatch?: (error: Error) => void
  children: Solid.JSX.Element
})

Source from the content-addressed store, hash-verified

5import type { NotFoundError } from '@tanstack/router-core'
6
7export 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
40export function DefaultGlobalNotFound() {
41 return <p>Not Found</p>

Callers

nothing calls this directly

Calls 2

useRouterStateFunction · 0.90
isNotFoundFunction · 0.90

Tested by

no test coverage detected