From 86089fa4f1383bd8d6a28a9c8a2e8cfac4ea9fb1 Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Sun, 29 Sep 2024 01:22:15 +0530 Subject: [PATCH] fix: max update depth fix --- .../pages/dashboard/usePerformanceOverview.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/webapp/pages/dashboard/usePerformanceOverview.ts b/src/webapp/pages/dashboard/usePerformanceOverview.ts index f771eefa..9df7440e 100644 --- a/src/webapp/pages/dashboard/usePerformanceOverview.ts +++ b/src/webapp/pages/dashboard/usePerformanceOverview.ts @@ -28,21 +28,20 @@ export function usePerformanceOverview(): State { const [order, setOrder] = useState(); useEffect(() => { - if (dataPerformanceOverview) { + if (dataPerformanceOverview.length && order) { setDataPerformanceOverview( (prevDataPerformanceOverview: PerformanceOverviewMetrics[]) => { const newDataPerformanceOverview = _(prevDataPerformanceOverview) .orderBy([ [ - (dataPerformanceOverviewData: PerformanceOverviewMetrics) => { - const value = - dataPerformanceOverviewData[order?.name || "creationDate"]; - return Number.isNaN(Number(value)) ? value : Number(value); - }, - order?.direction || "asc", + item => + Number.isNaN(Number(item[order.name])) + ? item[order.name] + : Number(item[order.name]), + order.direction, ], ]) - .value(); + .toArray(); return newDataPerformanceOverview; }