Local Storage Usage In React Using Axios
Hello, guys. Currently learning backend. I would like to as if my given code snippet is syntactically correct for storing user data from the database to local storage in react js.
7 Replies
I don't see red squiggles, so VSCode clearly thinks it is. Are you getting any errors?
So far I'm not getting errors, but do you think I code it the right way? Like, is that how it works?
it'll store some data in localstorage, yeah. It depends on how you use that data, and what data you're storing
Will it be accessible to all of my react components?
localstorage is a browser api, any code running in the browser will be able to access it
it's probably not the prefered way to pass around state in React though, but then that's a) a frontend question, and b) not something I personally know about 🙂
Okay, thanks. That solves that my question.
this entire question would've been better in #front-end, just for future reference. You're getting data through axios, but that doesn't make this a backend issue