@samitouri / QOS-React / commits / ba5b9c0af3

Add invariant

Defensive coding to prevent an infinite loop.

Andrew Clark committed Jan 31, 2017 at 11:35 UTC ba5b9c0af3d66a89b403edd05d94bc0470d84fea
1 file changed +7
src/renderers/shared/fiber/ReactFiberTreeReflection.js
+7
@@ -168,17 +168,24 @@ function findCurrentFiberUsingSlowPath(fiber : Fiber) : Fiber | null {
168 child = parentB.child;
169 while (child) {
170 if (child === a) {
171 + didFindChild = true;
172 a = parentB;
173 b = parentA;
174 break;
175 }
176 if (child === b) {
177 + didFindChild = true;
178 b = parentB;
179 a = parentA;
180 break;
181 }
182 child = child.sibling;
183 }
184 + invariant(
185 + didFindChild,
186 + 'Child was not found in either parent set. This indicates a bug ' +
187 + 'related to the return pointer.'
188 + );
189 }
190 }
191