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.
This commit is contained in:
Andrew Clark
2017-05-01 15:53:19 -07:00
parent ae4fa9ad94
commit 9145f40eb8
2 changed files with 3 additions and 4 deletions
@@ -260,7 +260,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
if (current === null) {
if (!workInProgress.stateNode) {
// In the initial pass we might need to construct the instance.
constructClassInstance(workInProgress);
constructClassInstance(workInProgress, workInProgress.pendingProps);
mountClassInstance(workInProgress, priorityLevel);
shouldUpdate = true;
} else {
@@ -285,9 +285,8 @@ module.exports = function(
ReactInstanceMap.set(instance, workInProgress);
}
function constructClassInstance(workInProgress: Fiber): any {
function constructClassInstance(workInProgress: Fiber, props: any): any {
const ctor = workInProgress.type;
const props = workInProgress.pendingProps;
const unmaskedContext = getUnmaskedContext(workInProgress);
const needsContext = isContextConsumer(workInProgress);
const context = needsContext
@@ -411,7 +410,7 @@ module.exports = function(
// If we didn't bail out we need to construct a new instance. We don't
// want to reuse one that failed to fully mount.
const newInstance = constructClassInstance(workInProgress);
const newInstance = constructClassInstance(workInProgress, newProps);
newInstance.props = newProps;
newInstance.state = newState = newInstance.state || null;
newInstance.context = newContext;