From fe94249b026f5e1b01197d5a13c50594eec3e850 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Mon, 18 May 2026 08:01:08 +0530 Subject: [PATCH] fixed setState error --- src/components/Dashboard/Dashboard.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Dashboard/Dashboard.tsx b/src/components/Dashboard/Dashboard.tsx index 9a815df..4ecd870 100644 --- a/src/components/Dashboard/Dashboard.tsx +++ b/src/components/Dashboard/Dashboard.tsx @@ -15,16 +15,16 @@ export default function Dashboard(props: DashboardProps) { event: React.MouseEvent, newFlow: "outflows" | "inflows" | null ) => { - if (newFlow !== null && newFlow !== state.flow) { - setState(prev => { - const next = { - ...prev, - flow: newFlow, - }; - props.onFlowChange?.(next); - return next; - }); - } + if (newFlow === null) return; + + setState(prev => { + if (prev.flow === newFlow) return prev; + + const next = { ...prev, flow: newFlow }; + props.onFlowChange?.(next); + + return next; + }); }; const togglePeriodType = () => {