For state management, we use:
React state
Redux state
Local storage
Session storage

That’s it 😊

  • 3
    Well 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.
  • 1
    Well, 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 πŸ˜…
  • 1
    Controlled 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.
  • 0
    @AmyShackles Last line, Ms. Shackles, last line!
  • 1
    @Cyanide I am… so sorry. πŸ˜…
  • 0
  • 1
    React state has the world inside itself.
    That's it πŸ˜‰
Add Comment