Skip to content

Commit 9d57f84

Browse files
authored
Merge pull request #49222 from gijoe0295/gijoe/49063
Fix: Unique `key` warning
2 parents 5bfc3f1 + f2f205b commit 9d57f84

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/components/AddressSearch/index.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react';
1+
import React, {forwardRef, useEffect, useMemo, useRef, useState} from 'react';
22
import type {ForwardedRef} from 'react';
33
import {ActivityIndicator, Keyboard, LogBox, View} from 'react-native';
44
import type {LayoutChangeEvent} from 'react-native';
@@ -329,12 +329,12 @@ function AddressSearch(
329329
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
330330
}, [predefinedPlaces, searchValue]);
331331

332-
const listEmptyComponent = useCallback(
333-
() => (!isTyping ? null : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>),
332+
const listEmptyComponent = useMemo(
333+
() => (!isTyping ? undefined : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>),
334334
[isTyping, styles, translate],
335335
);
336336

337-
const listLoader = useCallback(
337+
const listLoader = useMemo(
338338
() => (
339339
<View style={[styles.pv4]}>
340340
<ActivityIndicator
@@ -462,15 +462,14 @@ function AddressSearch(
462462
}}
463463
inbetweenCompo={
464464
// We want to show the current location button even if there are no recent destinations
465-
predefinedPlaces?.length === 0 &&
466-
shouldShowCurrentLocationButton && (
465+
predefinedPlaces?.length === 0 && shouldShowCurrentLocationButton ? (
467466
<View style={[StyleUtils.getGoogleListViewStyle(true), styles.overflowAuto, styles.borderLeft, styles.borderRight]}>
468467
<CurrentLocationButton
469468
onPress={getCurrentLocation}
470469
isDisabled={isOffline}
471470
/>
472471
</View>
473-
)
472+
) : undefined
474473
}
475474
placeholder=""
476475
listViewDisplayed

src/components/MenuItemList.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function MenuItemList({
8484
<>
8585
{menuItems.map((menuItemProps) => (
8686
<OfflineWithFeedback
87+
key={menuItemProps.key ?? menuItemProps.title}
8788
pendingAction={menuItemProps.pendingAction}
8889
onClose={menuItemProps.onPendingActionDismiss}
8990
errors={menuItemProps.error}

src/components/MoneyRequestConfirmationListFooter.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ function MoneyRequestConfirmationListFooter({
300300
},
301301
{
302302
item: (
303-
<MentionReportContext.Provider value={mentionReportContextValue}>
303+
<MentionReportContext.Provider
304+
key={translate('common.description')}
305+
value={mentionReportContextValue}
306+
>
304307
<MenuItemWithTopDescription
305308
key={translate('common.description')}
306309
shouldShowRightIcon={!isReadOnly}
@@ -504,7 +507,10 @@ function MoneyRequestConfirmationListFooter({
504507
},
505508
{
506509
item: (
507-
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}>
510+
<View
511+
key={translate('common.billable')}
512+
style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}
513+
>
508514
<ToggleSettingOptionRow
509515
switchAccessibilityLabel={translate('common.billable')}
510516
title={translate('common.billable')}
@@ -521,8 +527,8 @@ function MoneyRequestConfirmationListFooter({
521527
},
522528
];
523529

524-
const primaryFields: JSX.Element[] = [];
525-
const supplementaryFields: JSX.Element[] = [];
530+
const primaryFields: React.JSX.Element[] = [];
531+
const supplementaryFields: React.JSX.Element[] = [];
526532

527533
classifiedFields.forEach((field) => {
528534
if (field.shouldShow && !field.isSupplementary) {

0 commit comments

Comments
 (0)