Skip to content

Instantly share code, notes, and snippets.

@maberer
maberer / reactStateHandling.md
Last active August 29, 2015 14:14
Handling of batched state in react’s diff algorithm

#Some notes / further details based on the excellent article React’s diff algorithm

Assuming that react has batched multiple setState() calls that come from different component nodes (batched, because all calls happend before the js event loop ended), all of the given statements below are TRUE:

  • If multiple setState() calls are batched, react always looks first at the topmost dirty component and starts rendering from there.

  • React renders a tree of components until all dirty components have run/been touched exactly once.