From fd2e29afd92190b0b75dedc8be02bab4b201b759 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 6 Jul 2023 00:38:09 +0700 Subject: [PATCH] fix: null check --- .../TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.js | 4 +++- src/pages/settings/Security/TwoFactorAuth/VerifyPage.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.js b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.js index 3b9395661c6d..7455a19f1131 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.js +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.js @@ -54,7 +54,9 @@ function BaseTwoFactorAuthForm(props) { * Check that all the form fields are valid, then trigger the submit callback */ const validateAndSubmitForm = useCallback(() => { - inputRef.current.blur(); + if (inputRef.current) { + inputRef.current.blur(); + } if (!twoFactorAuthCode.trim()) { setFormError({twoFactorAuthCode: 'twoFactorAuthForm.error.pleaseFillTwoFactorAuth'}); return; diff --git a/src/pages/settings/Security/TwoFactorAuth/VerifyPage.js b/src/pages/settings/Security/TwoFactorAuth/VerifyPage.js index d487d7cc027f..8b91fdbe8693 100644 --- a/src/pages/settings/Security/TwoFactorAuth/VerifyPage.js +++ b/src/pages/settings/Security/TwoFactorAuth/VerifyPage.js @@ -150,6 +150,9 @@ function VerifyPage(props) { text={props.translate('common.next')} isLoading={props.account.isLoading} onPress={() => { + if (!formRef.current) { + return; + } formRef.current.validateAndSubmitForm(); }} />