fix: memoize date range in AnalyticsDashboard to prevent infinite refetch
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import { useAnalytics } from './useAnalytics';
|
||||
import FunnelChart from './charts/FunnelChart';
|
||||
import RevenueChart from './charts/RevenueChart';
|
||||
@@ -33,7 +33,7 @@ const KpiCard = ({ label, value, sub }) => (
|
||||
|
||||
const AnalyticsDashboard = () => {
|
||||
const [activeDays, setActiveDays] = useState(30);
|
||||
const { from, to } = getRange(activeDays);
|
||||
const { from, to } = useMemo(() => getRange(activeDays), [activeDays]);
|
||||
const {
|
||||
totalOrders, closedOrders, conversionRate,
|
||||
totalRevenue, avgDeal,
|
||||
|
||||
Reference in New Issue
Block a user