From 836e20e57e7c3897287ef176c5e05e4760246eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=20=28Claude=29?= Date: Sat, 13 Jun 2026 23:31:51 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20React=20error=20#301=20=E2=80=94=20load(?= =?UTF-8?q?)=20in=20render=20body=20=E2=86=92=20useEffect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Причина: load() вызывался прямо в теле компонента (не в useEffect), что триггерило setState → re-render → load() → бесконечный цикл. Исправлено в AdminPanel.js: SpendingSection: if (!data && !loading) load(period) → useEffect DashboardSection: if (!data...) { load() } × 2 → useEffect SettingsSection: if (!loaded && !loading) → useEffect PlansSection: if (loading && !plans.length) → useEffect Добавлен useEffect в import. --- components/AdminPanel.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/AdminPanel.js b/components/AdminPanel.js index cd3486b..dcd144b 100644 --- a/components/AdminPanel.js +++ b/components/AdminPanel.js @@ -1,5 +1,5 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Settings2, CreditCard, TrendingUp, Users, ChevronRight, Loader2, Eye, EyeOff, Save, RefreshCw, Check, AlertCircle, BarChart3, ArrowLeft, Zap, Tag, AlertTriangle, BookOpen, Sliders, Mail } from 'lucide-react'; import Link from 'next/link'; import AdminBilling from './admin/AdminBilling'; @@ -128,7 +128,7 @@ function SettingsSection({ categories }) { setLoading(false); } - if (!loaded && !loading) { load(); } + useEffect(() => { load(); }, []); return (
@@ -258,7 +258,7 @@ function SpendingSection() { setLoading(false); } - if (!data && !loading) load(period); + useEffect(() => { load(period); }, []); const totals = data?.totals || {}; const aiprimetech = byProv?.breakdown?.find(b => b.key === 'aiprimetech'); @@ -412,7 +412,7 @@ function PlansSection() { setSaving(s => ({ ...s, [`cost_${cost.operation}`]: false })); } - if (loading && !plans.length) { load(); } + useEffect(() => { load(); }, []); const PLAN_LABELS = { free: 'Free', starter: 'Starter', pro: 'Pro', business: 'Business' }; @@ -507,8 +507,7 @@ function DashboardSection() { setLoading(false); } - if (!data && !loading) load(); - if (!data && loading) { load(); } + useEffect(() => { load(); }, []); const PLATFORM_ICONS = { telegram: '✈️', vk: '🔵', max: '🟣' };