diff --git a/packages/uikit/src/pages/home/UnlockNotification.tsx b/packages/uikit/src/pages/home/UnlockNotification.tsx index 5096cf4d3..02d9d7624 100644 --- a/packages/uikit/src/pages/home/UnlockNotification.tsx +++ b/packages/uikit/src/pages/home/UnlockNotification.tsx @@ -62,9 +62,9 @@ export const PasswordUnlock: FC<{ }> = ({ sdk, onClose, onSubmit, isError, isLoading, padding }) => { const { t } = useTranslation(); const ref = useRef(null); - const [password, setPassword] = useState(''); - const [active, setActive] = useState(false); const location = useLocation(); + const previousLocation = useRef(location); + const [password, setPassword] = useState(''); useEffect(() => { sdk.uiEvents.on('navigate', onClose); @@ -85,12 +85,11 @@ export const PasswordUnlock: FC<{ }, []); useEffect(() => { - if (!active) { - setActive(true); - } else { + if (previousLocation.current !== location) { + previousLocation.current = location; onClose(); } - }, [location, active, onClose]); + }, [location, onClose]); const handleSubmit: React.FormEventHandler = async e => { e.preventDefault();