News for hackers. Stuff that matters.
Re:Persisting React State in LocalStorage by foota on Friday February 28, 2020 @01:21PM (#22444994)
Perhaps you could build the LS storage on top of a per-profile local storage?

I.e., you have something that on login creates a local storage key value for the active user, and then when someone logs out that is cleared (or it's keyed by user id and only used when that user is logged in). Components adding something need to add it to that key somehow, or could make use of prefixes. (the lack of structured data in local storage hurts a little here)

This way the thing managing the profile doesn't need to know what people are storing, and the components can still clear on logout.

Re:Persisting React State in LocalStorage by pault on Friday February 28, 2020 @02:42PM (#22445678)
I consider this a best practice. I always key my localstorage values to the user account and build version so you don't get issues with old localstorage schemas causing bugs when a new build is released.