From 8cd778ac5fe9aca99f24595cee91d70eeaf81c9f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 16 May 2022 13:34:30 +0200 Subject: [PATCH] Password Form: Correctly unmount component (#1875) --- src/components/common/PasswordForm.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/common/PasswordForm.tsx b/src/components/common/PasswordForm.tsx index cbcceae2..25eb2bf7 100644 --- a/src/components/common/PasswordForm.tsx +++ b/src/components/common/PasswordForm.tsx @@ -7,6 +7,7 @@ import { MIN_PASSWORD_LENGTH } from '../../config'; import { IS_TOUCH_ENV, IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment'; import buildClassName from '../../util/buildClassName'; import useLang from '../../hooks/useLang'; +import useTimeout from '../../hooks/useTimeout'; import Button from '../ui/Button'; @@ -44,13 +45,11 @@ const PasswordForm: FC = ({ const [password, setPassword] = useState(''); const [canSubmit, setCanSubmit] = useState(false); - useEffect(() => { + useTimeout(() => { if (!IS_TOUCH_ENV) { - setTimeout(() => { - inputRef.current!.focus(); - }, FOCUS_DELAY_TIMEOUT_MS); + inputRef.current!.focus(); } - }, []); + }, FOCUS_DELAY_TIMEOUT_MS); useEffect(() => { if (error) {