#next/navigation update?

8 messages · Page 1 of 1 (latest)

frozen trellis
#

useEffect(() => {
console.log("switching tabs")
console.log(router.pathname)
// Set the active tab based on the current pathname
setActiveTab(router.pathname);
}, [router.pathname]);

in my sidebar component I am tracking route changes like this to highlight my sidebar. however this hook only gets called on page reload not when I change paths using router.push

rancid willowBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

kind obsidian
#

Don't do router.pathname

#

const path = usePathname()

#

And put path in the deps arrays

#

@frozen trellis

frozen trellis
#

Bet thx

kind obsidian