fix: move setLoading to effect to satisfy react-hooks lint rule
This commit is contained in:
@@ -14,7 +14,6 @@ export function useAnalytics(dateFrom, dateTo) {
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
const fetchAnalytics = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const { data: orders, error: ordersError } = await supabase
|
||||
@@ -104,7 +103,10 @@ export function useAnalytics(dateFrom, dateTo) {
|
||||
setLoading(false);
|
||||
}, [dateFrom, dateTo]);
|
||||
|
||||
useEffect(() => { fetchAnalytics(); }, [fetchAnalytics]);
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
fetchAnalytics();
|
||||
}, [fetchAnalytics]);
|
||||
|
||||
return { ...analytics, loading, error };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user