Skip to content

Commit

Permalink
Don't double invoke getDerivedStateFromProps for module pattern (#21193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored Apr 7, 2021
1 parent e90c76a commit 782f689
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
11 changes: 0 additions & 11 deletions packages/react-reconciler/src/ReactFiberBeginWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ import {
} from './ReactFiberHydrationContext.new';
import {
adoptClassInstance,
applyDerivedStateFromProps,
constructClassInstance,
mountClassInstance,
resumeMountClassInstance,
Expand Down Expand Up @@ -1594,16 +1593,6 @@ function mountIndeterminateComponent(

initializeUpdateQueue(workInProgress);

const getDerivedStateFromProps = Component.getDerivedStateFromProps;
if (typeof getDerivedStateFromProps === 'function') {
applyDerivedStateFromProps(
workInProgress,
Component,
getDerivedStateFromProps,
props,
);
}

adoptClassInstance(workInProgress, value);
mountClassInstance(workInProgress, Component, props, renderLanes);
return finishClassComponent(
Expand Down
11 changes: 0 additions & 11 deletions packages/react-reconciler/src/ReactFiberBeginWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ import {
} from './ReactFiberHydrationContext.old';
import {
adoptClassInstance,
applyDerivedStateFromProps,
constructClassInstance,
mountClassInstance,
resumeMountClassInstance,
Expand Down Expand Up @@ -1594,16 +1593,6 @@ function mountIndeterminateComponent(

initializeUpdateQueue(workInProgress);

const getDerivedStateFromProps = Component.getDerivedStateFromProps;
if (typeof getDerivedStateFromProps === 'function') {
applyDerivedStateFromProps(
workInProgress,
Component,
getDerivedStateFromProps,
props,
);
}

adoptClassInstance(workInProgress, value);
mountClassInstance(workInProgress, Component, props, renderLanes);
return finishClassComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if (__DEV__) {
Object.freeze(fakeInternalInstance);
}

export function applyDerivedStateFromProps(
function applyDerivedStateFromProps(
workInProgress: Fiber,
ctor: any,
getDerivedStateFromProps: (props: any, state: any) => any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if (__DEV__) {
Object.freeze(fakeInternalInstance);
}

export function applyDerivedStateFromProps(
function applyDerivedStateFromProps(
workInProgress: Fiber,
ctor: any,
getDerivedStateFromProps: (props: any, state: any) => any,
Expand Down

0 comments on commit 782f689

Please sign in to comment.