|
1 | | -import {useIsFocused, useNavigation} from '@react-navigation/native'; |
| 1 | +import {useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native'; |
2 | 2 | import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; |
3 | 3 | import type {NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle, ViewToken} from 'react-native'; |
4 | 4 | import {View} from 'react-native'; |
@@ -174,10 +174,12 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS |
174 | 174 | const {translate} = useLocalize(); |
175 | 175 | const searchListRef = useRef<SelectionListHandle | null>(null); |
176 | 176 |
|
177 | | - useEffect(() => { |
178 | | - clearSelectedTransactions(hash); |
179 | | - setCurrentSearchHash(hash); |
180 | | - }, [hash, clearSelectedTransactions, setCurrentSearchHash]); |
| 177 | + useFocusEffect( |
| 178 | + useCallback(() => { |
| 179 | + clearSelectedTransactions(hash); |
| 180 | + setCurrentSearchHash(hash); |
| 181 | + }, [hash, clearSelectedTransactions, setCurrentSearchHash]), |
| 182 | + ); |
181 | 183 |
|
182 | 184 | const searchResults = currentSearchResults?.data ? currentSearchResults : lastNonEmptySearchResults; |
183 | 185 | const isSearchResultsEmpty = !searchResults?.data || isSearchResultsEmptyUtil(searchResults); |
|
0 commit comments