From 3b9121908ccf1a48557cbbcee7db0214ca7559f5 Mon Sep 17 00:00:00 2001 From: Bivekich Date: Fri, 8 Aug 2025 11:11:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=83?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=D0=BC=20=D1=81=D0=B0=D0=B9=D0=B4=D0=B1=D0=B0=D1=80=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=20AppShell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Реализован хук useEffect для отслеживания состояния монтирования компонента - Оптимизировано условие скрытия сайдбара в зависимости от маршрута, состояния загрузки и аутентификации пользователя - Устранен гидратационный рассинхрон при первом рендере --- src/components/layout/app-shell.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index 9fba4dd..a6d432f 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -1,13 +1,25 @@ 'use client' import { usePathname } from 'next/navigation' +import { useEffect, useState } from 'react' import { Sidebar } from '@/components/dashboard/sidebar' +import { useAuth } from '@/hooks/useAuth' export function AppShell({ children }: { children: React.ReactNode }) { const pathname = usePathname() + const { isAuthenticated, isLoading } = useAuth() + const [mounted, setMounted] = useState(false) - const hideSidebar = pathname === '/login' || pathname === '/register' + useEffect(() => { + setMounted(true) + }, []) + + const hideByRoute = + pathname === '/' || pathname?.startsWith('/login') || pathname?.startsWith('/register') + + // До маунта всегда скрываем сайдбар, чтобы избежать гидратационного рассинхрона + const hideSidebar = !mounted || hideByRoute || isLoading || !isAuthenticated return ( <>