DEV Community

Discussion on: Do you need a State Management Library?

Collapse
 
zaimazhar97 profile image
zaimazhar97

Hi...
I am a beginner Vue guy, sorry I invaded to this post.

My question is kinda general tho...

For example, if one of our component holds the state of username and we accidentally forgot to include that component in certain pages that requires username state. Will the state of username actually gone when we visit the page with that missing component? I've never build a huge application with moving states from one component to others. I just store the state inside localStorage and access it whenever I want but sometimes it bothers me that user can manipulate the state by injecting their own JS script inside the console.

The question is, what is the best approach if I want to keep the state globally while still able to access/manipulate it easily?

Thanks.

Collapse
 
link2twenty profile image
Andrew Bone

Hi, no need to apologise the more the merrier πŸ˜…

If we're talking about Vue specifically I'm afraid I don't really know it well enough to answer. I can link you to their documentation on state management though.

State Management β€” Vue.js

Collapse
 
zaimazhar97 profile image
zaimazhar97

Thank you ☺️

Collapse
 
jamesthomson profile image
James Thomson

I just store the state inside localStorage and access it whenever I want but sometimes it bothers me that user can manipulate the state by injecting their own JS script inside the console

Just to be clear, this is the case regardless of if you're using localStorage or a state management lib. Anything on the client should be considered accessible to the user.

Collapse
 
zaimazhar97 profile image
zaimazhar97

I've been bugging myself for quite some time about this. Now I can stop concerning too much about keeping state in localStorage.

Thank you. πŸ™‚

Thread Thread
 
jamesthomson profile image
James Thomson

Yes, don't worry about it unless it's sensitive information - that should never be stored on the client.