React Tree Reconciliation
Created on 2022-12-12T21:08:27-06:00
- Start with a cursor that walks over the old and new tree.
- If the types do not match: add destroying the old tree to tape, add the new tree from scratch.
- If types do match: the component is updated instead. Check for added, removed, and changed attributes. Write updating the attributes on an existing component to tape.
- When recursing in to a node React just looks to see which nodes are the same in a strictly ordered traversal. Adding to the end is cheap and the beginning is most expensive.
- Children can be given "keys." Child list is processed in to a set of keys and the set is used to detect which children have entered or exited the list. The set can also be analyzed to determine when elements have just been re-ordered.