From 220d8f08e2d5bb604ba79a1bed66bf44751496b3 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 20 Dec 2024 12:49:38 +0100 Subject: [PATCH] Migrate withOnyx to useOnyx and remove inexistent type --- .../TwoFactorAuthForm/BaseTwoFactorAuthForm.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.tsx b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.tsx index fe37aa9b228a..c7725f42c038 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/BaseTwoFactorAuthForm.tsx @@ -1,6 +1,6 @@ import React, {forwardRef, useCallback, useImperativeHandle, useRef, useState} from 'react'; -import type {ForwardedRef, RefAttributes} from 'react'; -import {withOnyx} from 'react-native-onyx'; +import type {ForwardedRef} from 'react'; +import {useOnyx} from 'react-native-onyx'; import type {AutoCompleteVariant, MagicCodeInputHandle} from '@components/MagicCodeInput'; import MagicCodeInput from '@components/MagicCodeInput'; import useLocalize from '@hooks/useLocalize'; @@ -8,9 +8,9 @@ import * as ErrorUtils from '@libs/ErrorUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import * as Session from '@userActions/Session'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {BaseTwoFactorAuthFormOnyxProps, BaseTwoFactorAuthFormRef} from './types'; +import type {BaseTwoFactorAuthFormRef} from './types'; -type BaseTwoFactorAuthFormProps = BaseTwoFactorAuthFormOnyxProps & { +type BaseTwoFactorAuthFormProps = { autoComplete: AutoCompleteVariant; // Set this to true in order to call the validateTwoFactorAuth action which is used when setting up 2FA for the first time. @@ -18,9 +18,10 @@ type BaseTwoFactorAuthFormProps = BaseTwoFactorAuthFormOnyxProps & { validateInsteadOfDisable?: boolean; }; -function BaseTwoFactorAuthForm({account, autoComplete, validateInsteadOfDisable}: BaseTwoFactorAuthFormProps, ref: ForwardedRef) { +function BaseTwoFactorAuthForm({autoComplete, validateInsteadOfDisable}: BaseTwoFactorAuthFormProps, ref: ForwardedRef) { const {translate} = useLocalize(); const [formError, setFormError] = useState<{twoFactorAuthCode?: string}>({}); + const [account] = useOnyx(ONYXKEYS.ACCOUNT); const [twoFactorAuthCode, setTwoFactorAuthCode] = useState(''); const inputRef = useRef(null); const shouldClearData = account?.needsTwoFactorAuthSetup ?? false; @@ -92,6 +93,4 @@ function BaseTwoFactorAuthForm({account, autoComplete, validateInsteadOfDisable} ); } -export default withOnyx, BaseTwoFactorAuthFormOnyxProps>({ - account: {key: ONYXKEYS.ACCOUNT}, -})(forwardRef(BaseTwoFactorAuthForm)); +export default forwardRef(BaseTwoFactorAuthForm);