diff --git a/src/routes/recipes_/$username.$slug.tsx b/src/routes/recipes_/$username.$slug.tsx index bcc6197..b87c474 100644 --- a/src/routes/recipes_/$username.$slug.tsx +++ b/src/routes/recipes_/$username.$slug.tsx @@ -1,8 +1,10 @@ import { createFileRoute, + ErrorComponent, useLoaderData, useParams } from '@tanstack/react-router' +import { ApiError } from '../../api/ApiError' import getRecipe from '../../api/getRecipe' import Recipe from '../../pages/recipe/Recipe' @@ -24,6 +26,16 @@ export const Route = createFileRoute('/recipes/$username/$slug')({ }) return }, + errorComponent({ error }) { + if (error instanceof ApiError) { + return ( +

+ {error.status}: {error.message} +

+ ) + } + return + }, notFoundComponent() { const { username, slug } = useParams({ from: '/recipes/$username/$slug'