import { useEffect, useRef, useState } from 'react'; import { Outlet, useLocation } from 'react-router-dom'; import Sidebar from './Sidebar'; import Header from './Header'; export default function Layout() { const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false); const mainRef = useRef(null); const { pathname } = useLocation(); // Scroll main content container to top on every route change useEffect(() => { if (mainRef.current) { mainRef.current.scrollTop = 0; } }, [pathname]); return (
setIsMobileSidebarOpen(false)} />
setIsMobileSidebarOpen(true)} />
); }