Next.js Discord

Discord Forum

Interactavibility with React Server Components

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
My site has a NavBar which ,on mobile, collapses and is opened using a burger icon. However, i cannot use useState with server components so i have to use "use client" in my entire navbar file, so that my burger icon alters the [opened] state. Is this a bad practice? Is it better if I loaded a script using next/script which enables an event listener which alters the class of nav so that it pops in? Generally, how can i manage state that is not user specific, like a dark-light theme toggle? Using external file with a variable and a getVar() and setVar() functions could lead to state being altered in the lambda and messing up other user's requests. Any insight is apreciated 🙂

4 Replies