Repository navigation
Split contexts to state and actions - Batch 3 #82631
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
Merged
mountiny
merged 17 commits into
Expensify:main
from
software-mansion-labs:perf/migrate-contexts-2
Feb 25, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
af8a21f
Migrate EnvironmentProvider
staszekscp bc77c5d
Migrate ThemeStylesProvider
staszekscp 266fbbc
Migrate FullScreenContextProvider
staszekscp 246b0e1
Migrate LockedAccountModalProvider
staszekscp 402aaad
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp 709fe85
Migrate LoginProvider
staszekscp 6fd2f31
Fix lint errors
staszekscp f461190
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp f83ef13
Fix TravelCVVPage.tsx
staszekscp eb6850a
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp 1a46c46
Add comment to ThemetylesContextProvider
staszekscp 840098b
Fix prettier
staszekscp 08450d9
Remove canBeMissing in migrated component
staszekscp c858427
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp 18ae060
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp eb74db8
Merge remote-tracking branch 'origin/main' into perf/migrate-contexts-2
staszekscp 4290481
Remove useCallback and useMemo in the compiled components
staszekscp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import CONST from '@src/CONST'; | ||
| import type {EnvironmentActionsContextType, EnvironmentStateContextType} from './types'; | ||
|
|
||
| const defaultEnvironmentStateContextValue: EnvironmentStateContextType = { | ||
| environment: CONST.ENVIRONMENT.PRODUCTION, | ||
| environmentURL: CONST.NEW_EXPENSIFY_URL, | ||
| }; | ||
|
|
||
| const defaultEnvironmentActionsContextValue: EnvironmentActionsContextType = { | ||
| adjustExpensifyLinksForEnv: () => '', | ||
| }; | ||
|
|
||
| export {defaultEnvironmentStateContextValue, defaultEnvironmentActionsContextValue}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type {ValueOf} from 'type-fest'; | ||
| import type CONST from '@src/CONST'; | ||
|
|
||
| type EnvironmentValue = ValueOf<typeof CONST.ENVIRONMENT>; | ||
|
|
||
| type EnvironmentStateContextType = { | ||
| /** The string value representing the current environment */ | ||
| environment: EnvironmentValue; | ||
|
|
||
| /** The string value representing the URL of the current environment */ | ||
| environmentURL: string; | ||
| }; | ||
|
|
||
| type EnvironmentActionsContextType = { | ||
| /** Adjusts Expensify links in the given HTML content to point to the current environment URL */ | ||
| adjustExpensifyLinksForEnv: (html: string) => string; | ||
| }; | ||
|
|
||
| export type {EnvironmentValue, EnvironmentStateContextType, EnvironmentActionsContextType}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import type {LockedAccountActionsContextType, LockedAccountStateContextType} from './types'; | ||
|
|
||
| const defaultLockedAccountStateContextValue: LockedAccountStateContextType = { | ||
| isAccountLocked: false, | ||
| }; | ||
|
|
||
| const defaultLockedAccountActionsContextValue: LockedAccountActionsContextType = { | ||
| showLockedAccountModal: () => {}, | ||
| }; | ||
|
|
||
| export {defaultLockedAccountStateContextValue, defaultLockedAccountActionsContextValue}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // This component is compiled by the React Compiler | ||
| /* eslint-disable react/jsx-no-constructed-context-values */ | ||
| import React, {createContext, useContext, useState} from 'react'; | ||
| import ConfirmModal from '@components/ConfirmModal'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import {defaultLockedAccountActionsContextValue, defaultLockedAccountStateContextValue} from './default'; | ||
| import type {LockedAccountActionsContextType, LockedAccountStateContextType} from './types'; | ||
|
|
||
| const LockedAccountStateContext = createContext<LockedAccountStateContextType>(defaultLockedAccountStateContextValue); | ||
| const LockedAccountActionsContext = createContext<LockedAccountActionsContextType>(defaultLockedAccountActionsContextValue); | ||
|
|
||
| function LockedAccountModalProvider({children}: React.PropsWithChildren) { | ||
| const {translate} = useLocalize(); | ||
| const [lockAccountDetails] = useOnyx(ONYXKEYS.NVP_PRIVATE_LOCK_ACCOUNT_DETAILS); | ||
| const isAccountLocked = lockAccountDetails?.isLocked ?? false; | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
|
||
| const stateValue = {isAccountLocked}; | ||
| const actionsValue = {showLockedAccountModal: () => setIsModalOpen(true)}; | ||
|
|
||
| return ( | ||
| <LockedAccountStateContext.Provider value={stateValue}> | ||
| <LockedAccountActionsContext.Provider value={actionsValue}> | ||
| {children} | ||
| <ConfirmModal | ||
| isVisible={isModalOpen} | ||
| onConfirm={() => setIsModalOpen(false)} | ||
| onCancel={() => setIsModalOpen(false)} | ||
| title={translate('lockedAccount.title')} | ||
| prompt={translate('lockedAccount.description')} | ||
| confirmText={translate('common.buttonConfirm')} | ||
| shouldShowCancelButton={false} | ||
| /> | ||
| </LockedAccountActionsContext.Provider> | ||
| </LockedAccountStateContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| function useLockedAccountState() { | ||
| return useContext(LockedAccountStateContext); | ||
| } | ||
|
|
||
| function useLockedAccountActions() { | ||
| return useContext(LockedAccountActionsContext); | ||
| } | ||
|
|
||
| export default LockedAccountModalProvider; | ||
| export {LockedAccountStateContext, LockedAccountActionsContext, useLockedAccountState, useLockedAccountActions}; | ||
| export type {LockedAccountStateContextType, LockedAccountActionsContextType}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| type LockedAccountStateContextType = { | ||
| isAccountLocked: boolean; | ||
| }; | ||
|
|
||
| type LockedAccountActionsContextType = { | ||
| showLockedAccountModal: () => void; | ||
| }; | ||
|
|
||
| export type {LockedAccountStateContextType, LockedAccountActionsContextType}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import {defaultStyles} from '@styles/index'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import {DefaultStyleUtils} from '@styles/utils'; | ||
| import type {ThemeStylesActionsContextType, ThemeStylesStateContextType} from './types'; | ||
|
|
||
| const defaultThemeStylesStateContextValue: ThemeStylesStateContextType = { | ||
| styles: defaultStyles, | ||
| }; | ||
|
|
||
| const defaultThemeStylesActionsContextValue: ThemeStylesActionsContextType = { | ||
| StyleUtils: DefaultStyleUtils, | ||
| }; | ||
|
|
||
| export {defaultThemeStylesStateContextValue, defaultThemeStylesActionsContextValue}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // This component is compiled by the React Compiler | ||
| /* eslint-disable react/jsx-no-constructed-context-values */ | ||
| import React, {createContext, useContext} from 'react'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import styles from '@styles/index'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import createStyleUtils from '@styles/utils'; | ||
| import {defaultThemeStylesActionsContextValue, defaultThemeStylesStateContextValue} from './default'; | ||
| import type {ThemeStylesActionsContextType, ThemeStylesStateContextType} from './types'; | ||
|
|
||
| const ThemeStylesStateContext = createContext<ThemeStylesStateContextType>(defaultThemeStylesStateContextValue); | ||
| const ThemeStylesActionsContext = createContext<ThemeStylesActionsContextType>(defaultThemeStylesActionsContextValue); | ||
|
|
||
| function ThemeStylesProvider({children}: React.PropsWithChildren) { | ||
| const theme = useTheme(); | ||
|
|
||
| const themeStyles = styles(theme); | ||
| const StyleUtils = createStyleUtils(theme, themeStyles); | ||
|
|
||
| const stateValue = {styles: themeStyles}; | ||
| const actionsValue = {StyleUtils}; | ||
|
|
||
| return ( | ||
| <ThemeStylesStateContext.Provider value={stateValue}> | ||
| <ThemeStylesActionsContext.Provider value={actionsValue}>{children}</ThemeStylesActionsContext.Provider> | ||
| </ThemeStylesStateContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| function useThemeStylesState() { | ||
| return useContext(ThemeStylesStateContext); | ||
| } | ||
|
|
||
| function useThemeStylesActions() { | ||
| return useContext(ThemeStylesActionsContext); | ||
| } | ||
|
|
||
| export default ThemeStylesProvider; | ||
| export {ThemeStylesStateContext, ThemeStylesActionsContext, useThemeStylesState, useThemeStylesActions}; | ||
| export type {ThemeStylesStateContextType, ThemeStylesActionsContextType}; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-5 (docs)
This
eslint-disableforreact/jsx-no-constructed-context-valueslacks an accompanying comment explaining why the rule is being disabled.The sibling file
LockedAccountModalProvider/index.tsxcorrectly includes a justification comment (// This component is compiled by the React Compiler) above its identical eslint-disable. Add the same justification here:Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.