Help with global state

I've fallen down one too many rabbit holes and could use some help. I have a number of toggle buttons on my website, and I need to know which are selected. I need to know this selection data on a few of my components, so I am trying to find a way to save this state. I've tried making a context, but none of the examples I could find compile. I tried sessionStorage which would save the old state on reload, which duplicated values. Still pretty new with nextjs/react/typescript. I am using the shadcn Toggle component, and I need to know which of my toggles are selected in the client.
1 Reply
Juraj98
Juraj985mo ago
Context is not ideal for things like this. While it can be done, I'd recommend you look at something like Jotai.
Want results from more Discord servers?
Add your server