Skip to content

Commit

Permalink
Don't double invoke getDerivedStateFromProps for module pattern (face…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored and acdlite committed Apr 11, 2021
1 parent 45005e5 commit 8e3dd8f
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 8e3dd8f

Please sign in to comment.