-
Notifications
You must be signed in to change notification settings - Fork 3.9k
chore: migrate AuthScreens from withOnyx to useOnyx #52417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
54ab17e
574a614
7cb691f
4472283
d40f037
e74210a
378812d
608a165
b738175
d66317b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import React, {memo, useEffect, useMemo, useRef, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import Onyx, {withOnyx} from 'react-native-onyx'; | ||
| import Onyx, {useOnyx} from 'react-native-onyx'; | ||
| import type {ValueOf} from 'type-fest'; | ||
| import ActiveGuidesEventListener from '@components/ActiveGuidesEventListener'; | ||
| import ComposeProviders from '@components/ComposeProviders'; | ||
| import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
| import OptionsListContextProvider from '@components/OptionListContextProvider'; | ||
| import {SearchContextProvider} from '@components/Search/SearchContext'; | ||
| import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRouterContext'; | ||
|
|
@@ -54,6 +55,7 @@ import SCREENS from '@src/SCREENS'; | |
| import type * as OnyxTypes from '@src/types/onyx'; | ||
| import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; | ||
| import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; | ||
| import beforeRemoveReportOpenedFromSearchRHP from './beforeRemoveReportOpenedFromSearchRHP'; | ||
| import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS'; | ||
|
|
@@ -604,15 +606,20 @@ const AuthScreensMemoized = memo(AuthScreens, () => true); | |
| // Migration to useOnyx cause re-login if logout from deeplinked report in desktop app | ||
| // Further analysis required and more details can be seen here: | ||
| // https://github.com/Expensify/App/issues/50560 | ||
| // eslint-disable-next-line | ||
| export default withOnyx<AuthScreensProps, AuthScreensProps>({ | ||
| session: { | ||
| key: ONYXKEYS.SESSION, | ||
| }, | ||
| lastOpenedPublicRoomID: { | ||
| key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID, | ||
| }, | ||
| initialLastUpdateIDAppliedToClient: { | ||
| key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, | ||
| }, | ||
| })(AuthScreensMemoized); | ||
| export default function AuthScreensWithOnyx() { | ||
| const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION); | ||
| const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); | ||
| const [initialLastUpdateIDAppliedToClient, initialLastUpdateIDAppliedToClientStatus] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); | ||
|
|
||
| if (isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus)) { | ||
| return <FullScreenLoadingIndicator />; | ||
| } | ||
|
|
||
| return ( | ||
| <AuthScreensMemoized | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see we usually fetch the data with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have followed this approach, @blazejkustra Has explained pretty neat here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Missed that comment. |
||
| session={session} | ||
| lastOpenedPublicRoomID={lastOpenedPublicRoomID} | ||
| initialLastUpdateIDAppliedToClient={initialLastUpdateIDAppliedToClient} | ||
| /> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.