DEV Community

Discussion on: Flawless React State Management: useReducer and Context API

Collapse
markerikson profile image
Mark Erikson

it only updates the components that actually are affected by a state difference

Depends on what you mean by "update" here.

Yes, React only modifies the DOM if your component's render output changes.

However, React always re-renders components recursively by default, even if the props and state haven't changed. It's a very common misconception that React automatically skips rendering if the props are the same - that's an optimization you have to apply.

See my post A (Mostly) Complete Guide to React Rendering Behavior for details.