From 3baf4d1a2cf2facedf08db73408e3f00f58bc69c Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Sat, 13 May 2023 23:13:51 +0200 Subject: [PATCH] feat: redirect to root in resistant not found --- src/routes/PageResistant.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/PageResistant.tsx b/src/routes/PageResistant.tsx index 6b28f1d..c6b782b 100644 --- a/src/routes/PageResistant.tsx +++ b/src/routes/PageResistant.tsx @@ -1,4 +1,4 @@ -import { useNavigate, useParams } from "react-router"; +import { redirect, useNavigate, useParams } from "react-router"; import { getResistantPhotoUrl } from "../getResistantPhotoUrl"; import { resistants } from "../resistants"; @@ -8,7 +8,10 @@ export const PageResistant = () => { const resistant = resistants.find((r) => r.id === idResistant); - if (!resistant) return <>RĂ©sistant introuvable; + if (!resistant) { + redirect("/"); + return <>RĂ©sistant introuvable; + } return ( <>