What is the difference between global state and the component status?

Keep everything all in one global state is one of the good practices in the use of Redux in development. However, some authors write that stored all the way up to the flags to control the modal Windows and other UI elements do not directly effect the business logic is overhead. Want to understand what's the difference (advantages, disadvantages, pitfalls) .

On the one hand seems to support the extension, it is convenient to encapsulate the state of a component inside it. If you need to change the behavior of a component, the developer only need to fix the code inside this component.

On the other hand, nothing prevents the state to be stored in the General store and working with them describe the action and reduciraj along with another code component.

In the end, the impression that the price for encapsulation, we transform the component into a black box. Maybe I'm something I'm missing?
March 23rd 20 at 18:43
1 answer
March 23rd 20 at 18:45
Keep everything all in one global state is one of the good practices in the use of Redux in the development


Who told you that?

for support and extension, it is convenient to encapsulate the state of a component inside it.


It's true

nothing prevents the state to be stored in the General store


Feel the difference between "to support and expand comfortable" and "do not interfere"?
"Nothing prevents" you to write anything - but what is the use?

the price for encapsulation, we transform the component into a black box

Yes. and it's good
> Who told you that?
The Authors Redux

I do not understand why it is good that the component is a black box. This fact complicates debugging. I mean, if something goes wrong in any scenario where this component is involved will still need to debug and work with his condition too. What is the benefit? - Shanon commented on March 23rd 20 at 18:48
The Authors Redux

A quote can lead?

This fact complicates debugging.

This simplifies debugging. I don't know why you call the component a "black box" as if you prohibit someone there to see. Component is a white box then it is.

If something goes wrong in the logic of the component, then you can just go on and debug it separately from the rest of the application. Even if tests write to.

If something goes wrong in another place with the participation of this component, due to the fact that you have a state component is in itself and a component is already tested and you are sure that it is okay - it reduces the number of things that you need to check in the global logic. Relative to the component - you only need to make sure that it correctly performs its external contract - in terms of interaction with other parts of the application. What he's going on the inside, you don't need to recheck. - Reece_Becker commented on March 23rd 20 at 18:51
@Shanon,

> Who told you that?
The Authors Redux

Dan Abramov in the response to this question wrote back. - sammie commented on March 23rd 20 at 18:54

Find more questions by tags ReduxReactJavaScript