From aac99d395bcb8943ac3829f6b2e2d6b7f7eb156e Mon Sep 17 00:00:00 2001 From: jacobkim9881 Date: Wed, 12 Feb 2025 11:48:10 +0900 Subject: [PATCH] deleted unneeded condition --- .../ValidateCodeActionForm/index.tsx | 22 ++++++++----------- src/components/ValidateCodeActionForm/type.ts | 3 --- .../Contacts/ContactMethodDetailsPage.tsx | 1 - 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/components/ValidateCodeActionForm/index.tsx b/src/components/ValidateCodeActionForm/index.tsx index cecee3aca981..bf30836d4ef9 100644 --- a/src/components/ValidateCodeActionForm/index.tsx +++ b/src/components/ValidateCodeActionForm/index.tsx @@ -9,7 +9,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ValidateCodeActionFormProps} from './type'; function ValidateCodeActionForm({ - isValidated, descriptionPrimary, descriptionSecondary, validatePendingAction, @@ -36,22 +35,19 @@ function ValidateCodeActionForm({ ); useEffect(() => { - if (hasMagicCodeBeenSent) { - // eslint-disable-next-line rulesdir/prefer-early-return - return () => { - // We need to run clearError in cleanup function to use as onClose function. - // As 'useEffect cleanup function' runs when even the component is unmounted, we need to put clearError() in the if condition. - // So clearError() will not run when the form is unmounted. - if (isClosedRef.current && !isValidated) { - clearError(); - } - }; - } if (!isInitialized.current) { isInitialized.current = true; sendValidateCode(); } - }, [isValidated, sendValidateCode, hasMagicCodeBeenSent, clearError]); + return () => { + // We need to run clearError in cleanup function to use as onClose function. + // As 'useEffect cleanup function' runs whenever a dependency is called, we need to put clearError() in the if condition. + // So clearError() will not run when the form is unmounted. + if (isClosedRef.current) { + clearError(); + } + }; + }, [sendValidateCode, clearError]); return ( diff --git a/src/components/ValidateCodeActionForm/type.ts b/src/components/ValidateCodeActionForm/type.ts index 8c33050315ea..3d579e5fc4bc 100644 --- a/src/components/ValidateCodeActionForm/type.ts +++ b/src/components/ValidateCodeActionForm/type.ts @@ -3,9 +3,6 @@ import type {ValidateCodeFormHandle} from '@components/ValidateCodeActionModal/V import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; type ValidateCodeActionFormProps = { - /** Wheter code is validated */ - isValidated: boolean; - /** Primary description of the modal */ descriptionPrimary: string; diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx index 25ea18009bd5..604793001390 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx +++ b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx @@ -329,7 +329,6 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { {isValidateCodeFormVisible && !loginData.validatedDate && !!loginData && ( validateSecondaryLogin(loginList, contactMethod, validateCode)} validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')}