DEV Community

Discussion on: When a simple React context gets out of hand.

Collapse
 
pathakpratik profile image
Pratik Pathak • Edited

Essentially this means even if just one value in state like selectedComment changes, the whole state refreshes and all components connected to the store re-render even though they do not depend on this value. Isn't creating separate contexts for a subtree of related components better?

Redux solves this problem by optimizing component re-rendering when state value changes so that only components that depends on it re-render.

Collapse
 
basicbrogrammer profile image
Jeremy Ward 😎🤓

Would it? I guess I can check the react performance gragph.

The way I understand it react would diff the current state and the new state then find the components for the diff. I'll run the react performance extension and report back 👍