Skip to content

Commit

Permalink
fix(routes): render breadcrumb for 404 pages
Browse files Browse the repository at this point in the history
This patch fixes an issue where the breadcrumbs relying on `match.data`
being defined would throw and surface an unhelpful error to users when
all we really wanted to do is show a 404 page.
  • Loading branch information
nicholaschiang committed Jul 23, 2023
1 parent a130aaf commit b300f82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/routes/_layout.products.$productId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useData } from 'utils'
export const handle: Handle = {
breadcrumb: (match) => (
<Link to={`/products/${match.params.productId as string}`}>
{(match.data as SerializeFrom<typeof loader>).name}
{(match.data as SerializeFrom<typeof loader>)?.name ?? '404'}
</Link>
),
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/shows.$showId/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { WhereToBuy } from './where-to-buy'
export const handle: Handle = {
breadcrumb: (match) => (
<Link to={`/shows/${match.params.showId as string}`}>
{(match.data as SerializeFrom<typeof loader>).name}
{(match.data as SerializeFrom<typeof loader>)?.name ?? '404'}
</Link>
),
}
Expand Down

0 comments on commit b300f82

Please sign in to comment.