React·100 questions

When should I use a global state manager (Redux/Zustand/Jotai)?

Answer

The need to use a global state manager, such as Redux, Zustand, or Jotai, arises as the codebase grows and the application architecture becomes more complex. Local component state and the mechanism of state lifting are no longer sufficient for efficient work.

The decision to introduce a global store is made based on the specific architectural needs of the project. There are a number of clear criteria indicating that the application genuinely needs a global state manager.

When a large number of disparate screens and components use the same data, and passing it down via props becomes impractical.
When advanced data caching, complex selectors for computations, or developer tools for debugging are required.
When the problem of prop drilling reaches critical proportions and makes code readability difficult.

At the same time, it is important to remember that you should not use a global store for local UI state that is only needed by one specific component. You should always weigh the cost of introducing the library and training the team to avoid overloading the project with unnecessary complexity.

Was this answer helpful?

More questions in this topic

Related questions from other topics