File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1- import { useEffect , useState } from 'react' ;
1+ import { useCallback , useEffect , useState } from 'react' ;
2+ import { usePathname } from 'next/navigation' ;
23import { styled } from '@mui/material/styles' ;
34import { withAuthGuard } from 'src/hocs/with-auth-guard' ;
45import { SideNav } from './side-nav' ;
56import { TopNav } from './top-nav' ;
6- import { usePathname } from 'next/navigation' ;
77
88const SIDE_NAV_WIDTH = 280 ;
99
@@ -26,15 +26,23 @@ const LayoutContainer = styled('div')({
2626export const Layout = withAuthGuard ( ( props ) => {
2727 const { children } = props ;
2828 const pathname = usePathname ( ) ;
29- const [ openNav , setOpenNav ] = useState ( true ) ;
29+ const [ openNav , setOpenNav ] = useState ( false ) ;
3030
31- useEffect (
31+ const handlePathnameChange = useCallback (
3232 ( ) => {
3333 if ( openNav ) {
3434 setOpenNav ( false ) ;
3535 }
3636 } ,
37- [ pathname , openNav ]
37+ [ openNav ]
38+ ) ;
39+
40+ useEffect (
41+ ( ) => {
42+ handlePathnameChange ( ) ;
43+ } ,
44+ // eslint-disable-next-line react-hooks/exhaustive-deps
45+ [ pathname ]
3846 ) ;
3947
4048 return (
You can’t perform that action at this time.
0 commit comments