-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Make InviteReceiptPartnerPolicyPage use new SelectionList
#76279
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -7,9 +7,9 @@ | |
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import PressableWithDelayToggle from '@components/Pressable/PressableWithDelayToggle'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import SelectionList from '@components/SelectionListWithSections'; | ||
| import type {ListItem} from '@components/SelectionListWithSections/types'; | ||
| import UserListItem from '@components/SelectionListWithSections/UserListItem'; | ||
| import SelectionList from '@components/SelectionList'; | ||
| import UserListItem from '@components/SelectionList/ListItem/UserListItem'; | ||
| import type {ListItem} from '@components/SelectionList/types'; | ||
| import TabSelector from '@components/TabSelector/TabSelector'; | ||
| import useDebouncedState from '@hooks/useDebouncedState'; | ||
| import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; | ||
|
|
@@ -247,7 +247,7 @@ | |
| [applyTabStatusFilter, getSearchStateForTab, members], | ||
| ); | ||
|
|
||
| const buildSections = useCallback( | ||
|
Check failure on line 250 in src/pages/workspace/receiptPartners/EditInviteReceiptPartnerPolicyPage.tsx
|
||
| (data: MemberForList[]) => [ | ||
| { | ||
| title: undefined, | ||
|
|
@@ -317,20 +317,21 @@ | |
| return ( | ||
| <TabScreenWithFocusTrapWrapper> | ||
| <SelectionList | ||
| data={filteredMembers} | ||
| ListItem={UserListItem} | ||
| onSelectRow={() => {}} | ||
| onDismissError={dismissError} | ||
| listItemWrapperStyle={styles.cursorDefault} | ||
| style={{listItemWrapperStyle: styles.cursorDefault}} | ||
| addBottomSafeAreaPadding | ||
|
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. ❌ PERF-4 (docs)Creating a new Suggested fix: Wrap the const textInputOptions = useMemo(() => ({
label: shouldShowTextInput ? translate('common.search') : undefined,
value: searchTerm,
onChangeText: setSearchTerm,
headerMessage: currentHeaderMessage,
}), [shouldShowTextInput, translate, searchTerm, setSearchTerm, currentHeaderMessage]);
// Then use:
<SelectionList
textInputOptions={textInputOptions}
// ...
/> |
||
| shouldShowTextInput={shouldShowTextInput} | ||
| textInputLabel={shouldShowTextInput ? translate('common.search') : undefined} | ||
| textInputValue={searchTerm} | ||
| onChangeText={setSearchTerm} | ||
| headerMessage={currentHeaderMessage} | ||
| sections={buildSections(filteredMembers)} | ||
| textInputOptions={{ | ||
| label: shouldShowTextInput ? translate('common.search') : undefined, | ||
| value: searchTerm, | ||
| onChangeText: setSearchTerm, | ||
| headerMessage: currentHeaderMessage, | ||
| }} | ||
| listEmptyContent={listEmptyContent} | ||
| shouldShowListEmptyContent={shouldShowListEmptyContent} | ||
| sectionListStyle={styles.pt3} | ||
| showListEmptyContent={shouldShowListEmptyContent} | ||
| /> | ||
| </TabScreenWithFocusTrapWrapper> | ||
| ); | ||
|
|
||
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.
❌ PERF-4 (docs)
Creating a new object literal
{listItemWrapperStyle: styles.cursorDefault}on every render breaks referential equality. IfSelectionListor its children are later memoized, this will prevent optimization.Suggested fix: Move the style object outside the render function or wrap it in
useMemo: