소스 검색

初期化中に画面が表示されないように修正

develop
sosuke.iwabuchi 2 년 전
부모
커밋
37ff679fbb
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. +5
    -1
      src/guards/AuthGuard.tsx

+ 5
- 1
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);


Loading…
취소
저장