Skip to content

Commit

Permalink
Refactor stats loading logic to handle errors more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Feb 22, 2025
1 parent bccbf2a commit 18d1ff9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/components/widgets/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ export const BoxWidget: FC<BoxWidgetProps> = ({

useEffect(() => {
setLoading(statsLoading);
if (data) {
setRefreshChildren((prev) => prev + 1);
setStats(data);
}
if (statsError) {
setStats(null);
console.error(`Failed to fetch stats: ${statsError}`);
} else if (data) {
setRefreshChildren((prev) => prev + 1);
setStats(data);
}
}, [data, statsLoading, statsError]);

Expand Down

0 comments on commit 18d1ff9

Please sign in to comment.