@@ -16,7 +16,6 @@ import {
1616 useRef ,
1717 useCallback ,
1818 useEffect ,
19- useLayoutEffect ,
2019 startTransition ,
2120 Suspense ,
2221} from 'react' ;
@@ -118,9 +117,7 @@ function Link({
118117 href,
119118 children,
120119 ...props
121- } : React . AnchorHTMLAttributes < HTMLAnchorElement > & {
122- onNavigate ?: ( ) => void ;
123- } ) {
120+ } : React . AnchorHTMLAttributes < HTMLAnchorElement > ) {
124121 return (
125122 < NextLink
126123 href = { `${ href } ` }
@@ -131,12 +128,11 @@ function Link({
131128 ) ;
132129}
133130
134- function NavItem ( { url, isActive, children, onNavigate } : any ) {
131+ function NavItem ( { url, isActive, children} : any ) {
135132 return (
136133 < div className = "flex flex-auto sm:flex-1" >
137134 < Link
138135 href = { url }
139- onNavigate = { onNavigate }
140136 className = { cn (
141137 'active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap' ,
142138 ! isActive && 'hover:bg-primary/5 hover:dark:bg-primary-dark/5' ,
@@ -173,21 +169,14 @@ export default function TopNav({
173169 const [ showSearch , setShowSearch ] = useState ( false ) ;
174170 const [ isScrolled , setIsScrolled ] = useState ( false ) ;
175171 const scrollParentRef = useRef < HTMLDivElement > ( null ) ;
176- const closeMenu = useCallback ( ( ) => setOpenMenuPath ( null ) , [ ] ) ;
177172 // Deriving from the path hides the menu as soon as a navigation commits.
178173 // Forget the path afterwards, so going Back doesn't reopen the menu.
179174 if ( openMenuPath !== null && openMenuPath !== asPath ) {
180- closeMenu ( ) ;
175+ setOpenMenuPath ( null ) ;
181176 }
182177 const isMenuOpen = openMenuPath === asPath ;
183178 const { breadcrumbs} = getRouteMeta ( asPath , routeTree ) ;
184179
185- // The mobile menu is transient UI. Reset it when Activity hides this route
186- // so going Back does not restore the menu in its open state.
187- useLayoutEffect ( ( ) => {
188- return ( ) => setOpenMenuPath ( null ) ;
189- } , [ ] ) ;
190-
191180 // HACK. Fix up the data structures instead.
192181 if ( ( routeTree as any ) . routes . length === 1 ) {
193182 routeTree = ( routeTree as any ) . routes [ 0 ] ;
@@ -428,28 +417,20 @@ export default function TopNav({
428417 { /* No fallback UI so need to be careful not to suspend directly inside. */ }
429418 < Suspense fallback = { null } >
430419 < div className = "ps-3 xs:ps-5 xs:gap-0.5 xs:text-base overflow-x-auto flex flex-row lg:hidden text-base font-bold text-secondary dark:text-secondary-dark" >
431- < NavItem
432- isActive = { section === 'learn' }
433- url = "/learn"
434- onNavigate = { closeMenu } >
420+ < NavItem isActive = { section === 'learn' } url = "/learn" >
435421 Learn
436422 </ NavItem >
437423 < NavItem
438424 isActive = { section === 'reference' }
439- url = "/reference/react"
440- onNavigate = { closeMenu } >
425+ url = "/reference/react" >
441426 Reference
442427 </ NavItem >
443428 < NavItem
444429 isActive = { section === 'community' }
445- url = "/community"
446- onNavigate = { closeMenu } >
430+ url = "/community" >
447431 Community
448432 </ NavItem >
449- < NavItem
450- isActive = { section === 'blog' }
451- url = "/blog"
452- onNavigate = { closeMenu } >
433+ < NavItem isActive = { section === 'blog' } url = "/blog" >
453434 Blog
454435 </ NavItem >
455436 </ div >
@@ -464,7 +445,6 @@ export default function TopNav({
464445 routeTree = { routeTree }
465446 breadcrumbs = { breadcrumbs }
466447 isForceExpanded = { isMenuOpen }
467- onNavigate = { closeMenu }
468448 />
469449 </ Suspense >
470450 < div className = "h-16" />
0 commit comments