Skip to content

Commit ce51fc4

Browse files
committed
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.
1 parent 8dcf9c7 commit ce51fc4

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/renderers/shared/fiber/ReactFiberBeginWork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
260260
if (current === null) {
261261
if (!workInProgress.stateNode) {
262262
// In the initial pass we might need to construct the instance.
263-
constructClassInstance(workInProgress);
263+
constructClassInstance(workInProgress, workInProgress.pendingProps);
264264
mountClassInstance(workInProgress, priorityLevel);
265265
shouldUpdate = true;
266266
} else {

src/renderers/shared/fiber/ReactFiberClassComponent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,8 @@ module.exports = function(
285285
ReactInstanceMap.set(instance, workInProgress);
286286
}
287287

288-
function constructClassInstance(workInProgress: Fiber): any {
288+
function constructClassInstance(workInProgress: Fiber, props: any): any {
289289
const ctor = workInProgress.type;
290-
const props = workInProgress.pendingProps;
291290
const unmaskedContext = getUnmaskedContext(workInProgress);
292291
const needsContext = isContextConsumer(workInProgress);
293292
const context = needsContext
@@ -411,7 +410,7 @@ module.exports = function(
411410

412411
// If we didn't bail out we need to construct a new instance. We don't
413412
// want to reuse one that failed to fully mount.
414-
const newInstance = constructClassInstance(workInProgress);
413+
const newInstance = constructClassInstance(workInProgress, newProps);
415414
newInstance.props = newProps;
416415
newInstance.state = newState = newInstance.state || null;
417416
newInstance.context = newContext;

0 commit comments

Comments
 (0)