fix: check location.state first
This commit is contained in:
parent
b386ee365f
commit
9996752d94
@ -39,11 +39,13 @@ export const Login = ({ onLogin }: LoginProps) => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const queryUsername = location.state.username;
|
||||
const queryPassword = location.state.password;
|
||||
if (queryUsername) setUsername(queryUsername);
|
||||
if (queryPassword) setPassword(queryPassword);
|
||||
navigate(location.pathname, { replace: true });
|
||||
if (location.state) {
|
||||
const queryUsername = location.state.username;
|
||||
const queryPassword = location.state.password;
|
||||
if (queryUsername) setUsername(queryUsername);
|
||||
if (queryPassword) setPassword(queryPassword);
|
||||
navigate(location.pathname, { replace: true });
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user