share state array between pages

Hey guys so the idea is pretty simple but I'm kinda stuck to achieve this. So I have functionality when I click a button I add id to the array, when I click it again I remove the id from the array. But now I want to use this array also in different page. For context I'm trying to build a "favorite list" so I probably need to preserve this array somehow, maybe with local storage? How should I go about this?
11 Replies
barry
barry3y ago
Zustand
barry
barry3y ago
GitHub
GitHub - pmndrs/zustand: 🐻 Bear necessities for state management in...
🐻 Bear necessities for state management in React. Contribute to pmndrs/zustand development by creating an account on GitHub.
noctate
noctateOP3y ago
ill look into it thx
barry
barry3y ago
GitHub
GitHub - barrybtw/zustand-example
Contribute to barrybtw/zustand-example development by creating an account on GitHub.
barry
barry3y ago
i made a tiny example with typescript ofc
noctate
noctateOP3y ago
ooh thx, that will be helpful for sure
barry
barry3y ago
if you wanted to persist on localstorage theres the persist middleware seen here: https://docs.pmnd.rs/zustand/integrations/persisting-store-data
Zustand Documentation
Zustand Documentation
Zustand is a small, fast and scalable bearbones state-management solution, it has a comfy api based on hooks
barry
barry3y ago
+ the docs
noctate
noctateOP3y ago
my eyes D: they should do dark mode 😄
barry
barry3y ago
lol yeah but its from poimandres same people from react three fiber, react spring, a11y, drei and other things they do cool stuff
noctate
noctateOP3y ago
yeah im ignorant and only for now know them from using their theme in vscode xD

Did you find this page helpful?