Skip to content

Commit 15b9751

Browse files
committed
replace useNavigate hook with redirect
1 parent 4048f58 commit 15b9751

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

interface/src/contexts/authentication/Authentication.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRequest } from 'alova';
22
import { useCallback, useEffect, useState } from 'react';
3-
import { useNavigate } from 'react-router-dom';
3+
import { redirect } from 'react-router-dom';
44
import { toast } from 'react-toastify';
55
import { AuthenticationContext } from './context';
66
import type { FC } from 'react';
@@ -15,8 +15,6 @@ import { useI18nContext } from 'i18n/i18n-react';
1515
const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
1616
const { LL } = useI18nContext();
1717

18-
const navigate = useNavigate();
19-
2018
const [initialized, setInitialized] = useState<boolean>(false);
2119
const [me, setMe] = useState<Me>();
2220

@@ -36,11 +34,12 @@ const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
3634
}
3735
};
3836

39-
const signOut = (redirect: boolean) => {
37+
const signOut = (doRedirect: boolean) => {
4038
AuthenticationApi.clearAccessToken();
4139
setMe(undefined);
42-
if (redirect) {
43-
navigate('/');
40+
if (doRedirect) {
41+
// navigate('/');
42+
redirect('/');
4443
}
4544
};
4645

0 commit comments

Comments
 (0)