Skip to content

Commit

Permalink
call cDM after setState is stubbed
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 authored and ljharb committed Aug 17, 2018
1 parent b412ec8 commit af8884b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,6 @@ class ShallowWrapper {
privateSet(this, RENDERER, renderer);
this[RENDERER].render(nodes, options.context);
({ instance } = this[RENDERER].getNode());
if (
!options.disableLifecycleMethods
&& instance
&& typeof instance.componentDidMount === 'function'
) {
this[RENDERER].batchedUpdates(() => {
instance.componentDidMount();
});
}
privateSetNodes(this, getRootNode(this[RENDERER].getNode()));
} else {
privateSet(this, ROOT, root);
Expand All @@ -202,6 +193,16 @@ class ShallowWrapper {
privateSet(instance, SET_STATE, instance.setState);
instance.setState = (...args) => this.setState(...args);
}

if (
!options.disableLifecycleMethods
&& instance
&& typeof instance.componentDidMount === 'function'
) {
this[RENDERER].batchedUpdates(() => {
instance.componentDidMount();
});
}
}

/**
Expand Down

0 comments on commit af8884b

Please sign in to comment.