Open History to see the last commit
1import {
2 ErrorComponent,
3 Link,
4 useLocation,
5 useRouter,
6} from '@tanstack/react-router'
7import type { ErrorComponentProps } from '@tanstack/react-router'
8β
9export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
10 const router = useRouter()
11 const isRoot = useLocation({
12 select: (location) => location.pathname === '/',
13 })
14β
15 console.error('DefaultCatchBoundary Error:', error)
16β
17 return (
18 <div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
19 <ErrorComponent error={error} />
20 <div className="flex gap-2 items-center flex-wrap">
21 <button
22 onClick={() => {
23 router.invalidate()
24 }}
25 className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
26 >
27 Try Again
28 </button>
29 {isRoot ? (
30 <Link
31 to="/"
32 search={{}}
33 className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
34 >
35 Home
36 </Link>
37 ) : (
38 <Link
39 to="/"
40 search={{}}
41 className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded-sm text-white uppercase font-extrabold`}
42 onClick={(e) => {
43 e.preventDefault()
44 window.history.back()
45 }}
46 >
47 Go Back
48 </Link>
49 )}
50 </div>
51 </div>
52 )
53}