From 37ff679fbbdea87d32a13a4a3e3d824865259373 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Mon, 30 Oct 2023 20:09:51 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=9C=9F=E5=8C=96=E4=B8=AD=E3=81=AB?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/guards/AuthGuard.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/guards/AuthGuard.tsx b/src/guards/AuthGuard.tsx index 08dca20..e318e05 100644 --- a/src/guards/AuthGuard.tsx +++ b/src/guards/AuthGuard.tsx @@ -5,7 +5,7 @@ import { useState } from "react"; import { Navigate, useLocation } from "react-router-dom"; export default function AuthGuard({ children }: HasChildren) { - const { authenticated } = useAuth(); + const { authenticated, initialized } = useAuth(); const { pathname } = useLocation(); @@ -13,6 +13,10 @@ export default function AuthGuard({ children }: HasChildren) { null ); + if (!initialized) { + return null; + } + if (!authenticated) { if (pathname !== requestedLocation) { setRequestedLocation(pathname);