Answer the question
In order to leave comments, you need to log in
What is the difference between global state and component state?
Keeping everything in the same global state is one of the best practices when using Redux in development. However, some authors write that storing everything up to the flags for managing modal windows and other UI elements that do not directly affect the business logic is an overhead. I want to understand the difference (pros, cons, pitfalls).
On the one hand, it seems convenient to encapsulate the state of a component within it for support and extension. If you need to change the behavior of a component, then the developer only needs to fix the code inside this component.
On the other hand, nothing prevents storing the state in a common store and describing how to work with it in actions and reducers along with other component code.
As a result, it seems that at the price of encapsulation, we turn the component into a black box. Perhaps I'm missing something?
Answer the question
In order to leave comments, you need to log in
Keeping everything in the same global state is one of the good practices when using Redux in development.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question