Skip to content

Commit

Permalink
replace useNavigate hook with redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 21, 2023
1 parent 4048f58 commit 15b9751
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions interface/src/contexts/authentication/Authentication.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,8 +15,6 @@ import { useI18nContext } from 'i18n/i18n-react';
const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
const { LL } = useI18nContext();

const navigate = useNavigate();

const [initialized, setInitialized] = useState<boolean>(false);
const [me, setMe] = useState<Me>();

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

const signOut = (redirect: boolean) => {
const signOut = (doRedirect: boolean) => {
AuthenticationApi.clearAccessToken();
setMe(undefined);
if (redirect) {
navigate('/');
if (doRedirect) {
// navigate('/');
redirect('/');
}
};

Expand Down

0 comments on commit 15b9751

Please sign in to comment.