Skip to content

Commit c1b60ac

Browse files
authored
Merge pull request Expensify#90609 from nabi-ebrahimi/fix/spend-group-selection-crash
Fix crash after selecting a group on the search page
2 parents 2a78e33 + c878f6a commit c1b60ac

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/components/Search/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {findFocusedRoute, useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native';
22
import * as Sentry from '@sentry/react-native';
3+
import {deepEqual} from 'fast-equals';
34
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
45
import type {NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle} from 'react-native';
56
import {View} from 'react-native';
@@ -878,6 +879,14 @@ function Search({
878879
return;
879880
}
880881

882+
// Bail out when the rebuilt selection is deeply equal to the current one. Without this,
883+
// a dep that re-derives to a new reference but the same value re-runs this effect, which
884+
// calls setSelectedTransactions with an equivalent payload and loops until React aborts
885+
// with "Maximum update depth exceeded". See https://github.com/Expensify/App/issues/89588
886+
if (deepEqual(newTransactionList, selectedTransactions)) {
887+
return;
888+
}
889+
881890
setSelectedTransactions(newTransactionList, filteredData);
882891

883892
isRefreshingSelection.current = true;

0 commit comments

Comments
 (0)