Skip to content

Commit fae3e53

Browse files
committed
Use memoizedState in componentDidUpdate
We forgot to clone this value so it didn't work before. This is covered by existing tests in ReactDOMProduction.
1 parent 685d65b commit fae3e53

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/renderers/shared/fiber/ReactFiber.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ exports.cloneFiber = function(fiber : Fiber, priorityLevel : PriorityLevel) : Fi
253253
alt.pendingWorkPriority = priorityLevel;
254254

255255
alt.memoizedProps = fiber.memoizedProps;
256+
alt.memoizedState = fiber.memoizedState;
256257
alt.output = fiber.output;
257258

258259
return alt;

src/renderers/shared/fiber/ReactFiberCommitWork.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
289289
} else {
290290
if (typeof instance.componentDidUpdate === 'function') {
291291
const prevProps = current.memoizedProps;
292-
// TODO: This is the new state. We don't currently have the previous
293-
// state anymore.
294-
const prevState = instance.state || null;
292+
const prevState = current.memoizedState;
295293
instance.componentDidUpdate(prevProps, prevState);
296294
}
297295
}

0 commit comments

Comments
 (0)