Skip to content

Instantly share code, notes, and snippets.

@adamcaron
Last active May 8, 2020 19:42
Show Gist options
  • Save adamcaron/ca51c23d430e3ae8d2c28d0b70ae0a2b to your computer and use it in GitHub Desktop.
Save adamcaron/ca51c23d430e3ae8d2c28d0b70ae0a2b to your computer and use it in GitHub Desktop.
State Management in React

State Management in React

Before understanding the concept of state management, you have to realize what a state is. A state in this context is the data layer of your application. When it comes to React and the libraries that help it manage state, you can say that state is an object that contains the data that your application is dealing with. For instance, if you want to display a list of items on your app, your state will contain the items you intend to display. State influences how React components behave and how they are rendered. Yes! It is as simple as that.

State management, therefore, means monitoring and managing the data (i.e., the state) of your app. Almost all apps have state in one way or the other and, as such, managing state has become one of the most important parts of building any modern app today.

Source: https://auth0.com/blog/managing-the-state-of-react-apps-with-mobx/

@adamcaron
Copy link
Author

adamcaron commented May 8, 2020

Context

Context API:

When you think about state management in React apps, basically, there are three alternatives:

  • Redux;
  • the new React Context API;
  • and MobX.

https://auth0.com/blog/react-context-api-managing-state-with-ease/


Do React Hooks Replace Redux?

TL;DR: Hooks are Great, but No.
https://medium.com/javascript-scene/do-react-hooks-replace-redux-210bab340672

Q: Of course, hooks don’t replace Redux. But hooks + React context replacing Redux? That’s the real question.
https://medium.com/@logancall.dev/of-course-hooks-dont-replace-redux-8941d3056d18#--responses

A: It’s possible to get the core app functionality without Redux, but still no, because you’ll miss out on the dev tools, automated action telemetry, etc, unless you essentially build an API compatible drop-in replacement. But why would you do that? React-Redux already uses context and hooks under the hood.
What do you think you would accomplish by skipping Redux?
https://medium.com/p/8941d3056d18/responses/show

@adamcaron
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment