@samitouri / QOS-React-2 / commits / 9145f40eb8

Fix bug where null props is passed to constructor when resuming mount

Another example of where the pending/progressed/memoized props model would benefit from a refactor.

Andrew Clark committed May 1, 2017 at 14:58 UTC 9145f40eb8948b1e10e0513dfd9b7f099408dff8
2 files changed +3 -4
src/renderers/shared/fiber/ReactFiberBeginWork.js
+1 -1
@@ -260,7 +260,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
260 if (current === null) {
261 if (!workInProgress.stateNode) {
262 // In the initial pass we might need to construct the instance.
263 - constructClassInstance(workInProgress);
263 + constructClassInstance(workInProgress, workInProgress.pendingProps);
264 mountClassInstance(workInProgress, priorityLevel);
265 shouldUpdate = true;
266 } else {
src/renderers/shared/fiber/ReactFiberClassComponent.js
+2 -3
@@ -285,9 +285,8 @@ module.exports = function(
285 ReactInstanceMap.set(instance, workInProgress);
286 }
287
288 - function constructClassInstance(workInProgress: Fiber): any {
288 + function constructClassInstance(workInProgress: Fiber, props: any): any {
289 const ctor = workInProgress.type;
290 - const props = workInProgress.pendingProps;
290 const unmaskedContext = getUnmaskedContext(workInProgress);
291 const needsContext = isContextConsumer(workInProgress);
292 const context = needsContext
@@ -411,7 +410,7 @@ module.exports = function(
410
411 // If we didn't bail out we need to construct a new instance. We don't
412 // want to reuse one that failed to fully mount.
414 - const newInstance = constructClassInstance(workInProgress);
413 + const newInstance = constructClassInstance(workInProgress, newProps);
414 newInstance.props = newProps;
415 newInstance.state = newState = newInstance.state || null;
416 newInstance.context = newContext;