Skip to content

Commit

Permalink
[Fix] shallow: ensure that if gDSFP exists, cDU is called.
Browse files Browse the repository at this point in the history
  • Loading branch information
peanutenthusiast authored and ljharb committed Mar 13, 2019
1 parent 80d9f71 commit 275b0b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class ShallowWrapper {
// this case, state will be undefined, but props/context will exist.
const node = this[RENDERER].getNode();
const instance = node.instance || {};
const type = node.type || {};
const { state } = instance;
const prevProps = instance.props || this[UNRENDERED].props;
const prevContext = instance.context || this[OPTIONS].context;
Expand Down Expand Up @@ -522,7 +523,11 @@ class ShallowWrapper {
if (
lifecycles.componentDidUpdate
&& typeof instance.componentDidUpdate === 'function'
&& (!state || shallowEqual(state, this.instance().state))
&& (
!state
|| shallowEqual(state, this.instance().state)
|| typeof type.getDerivedStateFromProps === 'function'
)
) {
instance.componentDidUpdate(prevProps, state, snapshot);
}
Expand Down

0 comments on commit 275b0b3

Please sign in to comment.