Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Crost4200289dWell dry isn't always good if you try to shoe horn in different requirements into 1 mechanism
Apart from the first 2 not being the same thing - makes sense to me.
fullstackclown5992288dWell, they're different use cases, aren't they? Local storage will persist even after they open / close the app (sounds like this is a native app?) Redux has a fresh state when the app / webpage is opened... session also, I suppose, depending on how the user interacts with the API.
Finally, a small amount of local React state is fine, I think it clutters the codebase if you make EVERY stateful value a redux state for something as simple as something like some text or toggle value that is only used in a single component...
HOWEVER, if all these layers are tracking the same exact values for the state, then yes, that is very stupid.
Otherwise, I don't see a problem here 😅
AmyShackles6758287dControlled components: React state
State maintained regardless of navigation: Redux state
Persisted state without expiry: local storage
Persisted state with expiry/tab context: session storage
If you have different use cases for different types of state management, it makes sense to have multiple ways of managing state. If the rules you have regarding which state management to use for any given thing and the areas of responsibility are clearly defined it’s not so bad.
If no one knows how to use each or why is when you run into issues.
Eklavya1749287dReact state has the world inside itself.
That's it 😉