Finish comment in ReactDOMComponentTree
Ben Alpert committed
Nov 17, 2015 at 09:41 UTC
6c89857cdca02ef3372ab9dc86dd059dc1e99b83
2 files changed
+6
-2
src/renderers/dom/client/ReactDOMComponentTree.js
+4
-1
@@ -64,7 +64,10 @@ function uncacheNode(inst) {
64
* node every time.
65
*
66
* Since we update `_renderedChildren` and the actual DOM at (slightly)
67
- * different times, we could race here and not get the
67
+ * different times, we could race here and see a newer `_renderedChildren` than
68
+ * the DOM nodes we see. To avoid this, ReactMultiChild calls
69
+ * `prepareToManageChildren` before we change `_renderedChildren`, at which
70
+ * time the container's child nodes are always cached (until it unmounts).
71
*/
72
function precacheChildNodes(inst, node) {
73
if (inst._flags & Flags.hasCachedChildNodes) {
src/renderers/dom/shared/ReactDOMComponent.js
+2
-1
@@ -1201,7 +1201,8 @@ assign(
1201
prepareToManageChildren: function() {
1202
// Before we add, remove, or reorder the children of a node, make sure
1203
// we have references to all of its children so we don't lose them, even
1204
- // if nefarious browser plugins add extra nodes to our tree.
1204
+ // if nefarious browser plugins add extra nodes to our tree. This could be
1205
+ // called once per child so it should be fast.
1206
ReactDOMComponentTree.precacheChildNodes(this, getNode(this));
1207
},
1208
}