From 2d9ef25d6171890496b1c9dd48a91b11c40eca7c Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Mon, 6 Dec 2021 20:46:35 +0800
Subject: ...

---
 FrontEnd/src/views/login/index.tsx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'FrontEnd/src/views/login/index.tsx')

diff --git a/FrontEnd/src/views/login/index.tsx b/FrontEnd/src/views/login/index.tsx
index a3f0ccd7..3a1ccfc4 100644
--- a/FrontEnd/src/views/login/index.tsx
+++ b/FrontEnd/src/views/login/index.tsx
@@ -1,5 +1,5 @@
 import React from "react";
-import { useHistory } from "react-router";
+import { useNavigate } from "react-router-dom";
 import { useTranslation } from "react-i18next";
 
 import { useUser, userService } from "@/services/user";
@@ -11,7 +11,9 @@ import "./index.css";
 
 const LoginPage: React.FC = (_) => {
   const { t } = useTranslation();
-  const history = useHistory();
+
+  const navigate = useNavigate();
+
   const [username, setUsername] = React.useState<string>("");
   const [usernameDirty, setUsernameDirty] = React.useState<boolean>(false);
   const [password, setPassword] = React.useState<string>("");
@@ -24,12 +26,12 @@ const LoginPage: React.FC = (_) => {
 
   React.useEffect(() => {
     if (user != null) {
-      const id = setTimeout(() => history.push("/"), 3000);
+      const id = setTimeout(() => navigate("/"), 3000);
       return () => {
         clearTimeout(id);
       };
     }
-  }, [history, user]);
+  }, [navigate, user]);
 
   if (user != null) {
     return (
@@ -59,9 +61,9 @@ const LoginPage: React.FC = (_) => {
       .then(
         () => {
           if (history.length === 0) {
-            history.push("/");
+            navigate("/");
           } else {
-            history.goBack();
+            navigate(-1);
           }
         },
         (e: Error) => {
-- 
cgit v1.2.3

