From 15b97515bb54686afff897a69669dacd451da5b4 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 21 Oct 2023 16:14:02 +0200 Subject: [PATCH] replace useNavigate hook with redirect --- .../src/contexts/authentication/Authentication.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/interface/src/contexts/authentication/Authentication.tsx b/interface/src/contexts/authentication/Authentication.tsx index bf9e05bae..bc972aaa1 100644 --- a/interface/src/contexts/authentication/Authentication.tsx +++ b/interface/src/contexts/authentication/Authentication.tsx @@ -1,6 +1,6 @@ import { useRequest } from 'alova'; import { useCallback, useEffect, useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { redirect } from 'react-router-dom'; import { toast } from 'react-toastify'; import { AuthenticationContext } from './context'; import type { FC } from 'react'; @@ -15,8 +15,6 @@ import { useI18nContext } from 'i18n/i18n-react'; const Authentication: FC = ({ children }) => { const { LL } = useI18nContext(); - const navigate = useNavigate(); - const [initialized, setInitialized] = useState(false); const [me, setMe] = useState(); @@ -36,11 +34,12 @@ const Authentication: FC = ({ children }) => { } }; - const signOut = (redirect: boolean) => { + const signOut = (doRedirect: boolean) => { AuthenticationApi.clearAccessToken(); setMe(undefined); - if (redirect) { - navigate('/'); + if (doRedirect) { + // navigate('/'); + redirect('/'); } };