What happens when you call setState?

August 02, 2018

When you call setState, React takes the data you passed in and merges it into the current state of your component. This kicks off a process to update the DOM in the most efficient way possible.

To perform this update, React renders a tree of components in the virtual DOM, diffs the tree against the previous one, and updates the actual UI where necessary.

I'm sharing everything I learn while building a software company. Join my newsletter to receive advice and opportunities that I never post publicly. Or learn more about me?