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 committed 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
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
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
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
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.