Harden assertions

This commit is contained in:
Dan Abramov
2019-04-19 00:29:49 +01:00
parent 3dfbf8ad6b
commit ccecde76d1
2 changed files with 23 additions and 9 deletions
+18 -1
View File
@@ -711,9 +711,17 @@ export default class Store extends EventEmitter {
element = ((this._idToElement.get(id): any): Element);
parentID = element.parentID;
weightDelta = -element.weight;
if (element.children.length > 0) {
throw new Error(
'Fiber ' +
id +
' was removed before its children. ' +
'This is a bug in React DevTools.'
);
}
this._idToElement.delete(id);
if (parentID === 0) {
@@ -769,7 +777,16 @@ export default class Store extends EventEmitter {
}
element = ((this._idToElement.get(id): any): Element);
const prevChildren = element.children;
element.children = Array.from(children);
if (element.children.length !== prevChildren.length) {
throw new Error(
'Fiber ' +
id +
' received a different number of children on reorder. ' +
'This is a bug in React DevTools.'
);
}
if (!element.isCollapsed) {
const prevWeight = element.weight;