#Active link styles in a Server Component?

4 messages · Page 1 of 1 (latest)

frozen raven
#

I'm watching a tutorial. The guy uses usePathname to determine active link styles. This forces the component to be a Client Component.

Could it not remain as a Server Component if he had elected to use the server props that give the current pathname? Or is it the nature of a Client Component that allows the active styles to dynamically change?

cedar tapirBOT
#

🔎 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)

atomic trellis
#

well... usePathname is the only function to get the pathname and this hook is only clientside. So they NEED to be clientside. You may be confused, because you can get the searchparams serverside @frozen raven

frozen raven