aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/login
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-12-06 20:46:35 +0800
committercrupest <crupest@outlook.com>2021-12-06 20:46:35 +0800
commit2d9ef25d6171890496b1c9dd48a91b11c40eca7c (patch)
treeac48193d08296dd880005e8e0399b0b48a4bcc5d /FrontEnd/src/views/login
parentde0c85ca334d06f042e685b8263a3261b8f8b055 (diff)
downloadtimeline-2d9ef25d6171890496b1c9dd48a91b11c40eca7c.tar.gz
timeline-2d9ef25d6171890496b1c9dd48a91b11c40eca7c.tar.bz2
timeline-2d9ef25d6171890496b1c9dd48a91b11c40eca7c.zip
...
Diffstat (limited to 'FrontEnd/src/views/login')
-rw-r--r--FrontEnd/src/views/login/index.tsx14
1 files changed, 8 insertions, 6 deletions
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) => {