Active link styles in a Server Component?
Answered
Pink salmon posted this in #help-forum
Pink salmonOP
I'm watching a tutorial. The guy uses
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?
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?
Answered by B33fb0n3
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 @Pink salmon
2 Replies
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 @Pink salmon
Answer
Pink salmonOP
You're right, thank you for clarifying this! Have a good day.