mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user