fix: check location.state first

This commit is contained in:
2025-03-11 08:42:44 +01:00
parent b386ee365f
commit 9996752d94

View File

@@ -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 (