Skip to content

Commit 8dacb69

Browse files
committed
fix: error boundaries
1 parent 44fe38b commit 8dacb69

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"next-themes": "^0.4.6",
3939
"react": "^19.2.1",
4040
"react-dom": "^19.2.1",
41+
"react-error-boundary": "^6.1.0",
4142
"react-icons": "^5.5.0",
4243
"react-spinners": "^0.17.0",
4344
"sonner": "^2.0.7",

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/PathBreadcrumb.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useSuspenseQuery } from "@tanstack/react-query"
22
import { Link, useParams } from "@tanstack/react-router"
33
import { Suspense } from "react"
4+
import { ErrorBoundary } from "react-error-boundary"
45
import { LuArrowRight, LuHouse } from "react-icons/lu"
56
import { useQueries } from "@/hooks/use-queries"
67
import { numberToRoman } from "@/utils/strings/numbers"
@@ -41,10 +42,12 @@ export default function PathBreadcrumb() {
4142
</div>
4243
{params.id && (
4344
<Suspense fallback={null}>
44-
<div className="flex items-center justify-center gap-2">
45-
<LuArrowRight size={18} />
46-
<RankingInfo id={params.id} withBadgeOutline />
47-
</div>
45+
<ErrorBoundary fallback={null}>
46+
<div className="flex items-center justify-center gap-2">
47+
<LuArrowRight size={18} />
48+
<RankingInfo id={params.id} withBadgeOutline />
49+
</div>
50+
</ErrorBoundary>
4851
</Suspense>
4952
)}
5053
</div>
@@ -63,8 +66,6 @@ export function RankingInfo({
6366
const q = useQueries()
6467
const ranking = useSuspenseQuery(q.ranking(id))
6568

66-
if (ranking.error) return null
67-
6869
const Content = () => (
6970
<>
7071
<Badge

0 commit comments

Comments
 (0)