diff --git a/src/pages/LogOutPreviousUserPage.tsx b/src/pages/LogOutPreviousUserPage.tsx index 260fe8942926..5e40342a7b9d 100644 --- a/src/pages/LogOutPreviousUserPage.tsx +++ b/src/pages/LogOutPreviousUserPage.tsx @@ -1,8 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useContext, useEffect} from 'react'; import {NativeModules} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import {InitialURLContext} from '@components/InitialURLContextProvider'; import * as SessionUtils from '@libs/SessionUtils'; @@ -14,24 +13,18 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Route} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Session} from '@src/types/onyx'; -type LogOutPreviousUserPageOnyxProps = { - /** The data about the current session which will be set once the user is authenticated and we return to this component as an AuthScreen */ - session: OnyxEntry; - - /** Is the account loading? */ - isAccountLoading: boolean; -}; - -type LogOutPreviousUserPageProps = LogOutPreviousUserPageOnyxProps & StackScreenProps; +type LogOutPreviousUserPageProps = StackScreenProps; // This page is responsible for handling transitions from OldDot. Specifically, it logs the current user // out if the transition is for another user. // // This component should not do any other navigation as that handled in App.setUpPoliciesAndNavigate -function LogOutPreviousUserPage({session, route, isAccountLoading}: LogOutPreviousUserPageProps) { +function LogOutPreviousUserPage({route}: LogOutPreviousUserPageProps) { const {initialURL} = useContext(InitialURLContext); + const [session] = useOnyx(ONYXKEYS.SESSION); + const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT); + const isAccountLoading = account?.isLoading; useEffect(() => { const sessionEmail = session?.email; @@ -92,12 +85,4 @@ function LogOutPreviousUserPage({session, route, isAccountLoading}: LogOutPrevio LogOutPreviousUserPage.displayName = 'LogOutPreviousUserPage'; -export default withOnyx({ - isAccountLoading: { - key: ONYXKEYS.ACCOUNT, - selector: (account) => account?.isLoading ?? false, - }, - session: { - key: ONYXKEYS.SESSION, - }, -})(LogOutPreviousUserPage); +export default LogOutPreviousUserPage; diff --git a/src/pages/signin/SAMLSignInPage/index.native.tsx b/src/pages/signin/SAMLSignInPage/index.native.tsx index 9ce73b675320..3b9bc456a680 100644 --- a/src/pages/signin/SAMLSignInPage/index.native.tsx +++ b/src/pages/signin/SAMLSignInPage/index.native.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useState} from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import WebView from 'react-native-webview'; import type {WebViewNativeEvent} from 'react-native-webview/lib/WebViewTypes'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; @@ -13,9 +13,10 @@ import * as Session from '@userActions/Session'; import CONFIG from '@src/CONFIG'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {SAMLSignInPageOnyxProps, SAMLSignInPageProps} from './types'; -function SAMLSignInPage({credentials, account}: SAMLSignInPageProps) { +function SAMLSignInPage() { + const [account] = useOnyx(ONYXKEYS.ACCOUNT); + const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS); const samlLoginURL = `${CONFIG.EXPENSIFY.SAML_URL}?email=${credentials?.login}&referer=${CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER}&platform=${getPlatform()}`; const [showNavigation, shouldShowNavigation] = useState(true); @@ -80,7 +81,4 @@ function SAMLSignInPage({credentials, account}: SAMLSignInPageProps) { SAMLSignInPage.displayName = 'SAMLSignInPage'; -export default withOnyx({ - credentials: {key: ONYXKEYS.CREDENTIALS}, - account: {key: ONYXKEYS.ACCOUNT}, -})(SAMLSignInPage); +export default SAMLSignInPage;