Skip to content

Commit 8d5f14e

Browse files
committed
fix: SpendOverTime widget not updating data when switching tabs
1 parent 71a4eb6 commit 8d5f14e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/pages/home/SpendOverTimeSection/useSpendOverTimeData.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useIsFocused} from '@react-navigation/native';
12
import {useEffect, useEffectEvent} from 'react';
23
import type {OnyxEntry} from 'react-native-onyx';
34
import type {ValueOf} from 'type-fest';
@@ -56,6 +57,7 @@ function useSpendOverTimeData() {
5657
const isSearchLoading = !!searchResults?.search?.isLoading;
5758

5859
const {isOffline} = useNetwork();
60+
const isFocused = useIsFocused();
5961

6062
const onConfigChanged = useEffectEvent(() => {
6163
if (!queryJSON || isSearchLoading || isOffline) {
@@ -73,8 +75,11 @@ function useSpendOverTimeData() {
7375
});
7476

7577
useEffect(() => {
78+
if (!isFocused) {
79+
return;
80+
}
7681
onConfigChanged();
77-
}, [config.hash, isOffline]);
82+
}, [config.hash, isOffline, isFocused]);
7883

7984
const sortedData =
8085
searchResults?.data && queryJSON && groupBy && login

0 commit comments

Comments
 (0)