From 9996752d94144ad3f50cf83a89824afb3c61ab2d Mon Sep 17 00:00:00 2001 From: julius Date: Tue, 11 Mar 2025 08:42:44 +0100 Subject: [PATCH] fix: check location.state first --- src/Login.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Login.tsx b/src/Login.tsx index 308a289..ae31add 100644 --- a/src/Login.tsx +++ b/src/Login.tsx @@ -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 (