Skip to content

Commit

Permalink
[enzyme-adapter-react-{16,16.3}] [fix] add `hasShouldComponentUpdateB…
Browse files Browse the repository at this point in the history
…ug` to gDSFP lifecycles option
  • Loading branch information
ljharb committed Mar 11, 2019
1 parent e2dc30d commit d686c91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ class ReactSixteenThreeAdapter extends EnzymeAdapter {
componentDidUpdate: {
onSetState: true,
},
getDerivedStateFromProps: true,
getDerivedStateFromProps: {
hasShouldComponentUpdateBug: true,
},
getSnapshotBeforeUpdate: true,
setState: {
skipsComponentDidUpdateOnNullish: true,
Expand Down
7 changes: 5 additions & 2 deletions packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import detectFiberTags from './detectFiberTags';
const is164 = !!TestUtils.Simulate.touchStart; // 16.4+
const is165 = !!TestUtils.Simulate.auxClick; // 16.5+
const is166 = is165 && !React.unstable_AsyncMode; // 16.6+
const is168 = is166 && typeof TestUtils.act === 'function';

// Lazily populated if DOM is available.
let FiberTags = null;
Expand Down Expand Up @@ -280,7 +281,7 @@ function getEmptyStateValue() {
}

function wrapAct(fn) {
if (typeof TestUtils.act !== 'function') {
if (!is168) {
return fn();
}
let returnVal;
Expand All @@ -301,7 +302,9 @@ class ReactSixteenAdapter extends EnzymeAdapter {
componentDidUpdate: {
onSetState: true,
},
getDerivedStateFromProps: true,
getDerivedStateFromProps: {
hasShouldComponentUpdateBug: !is168,
},
getSnapshotBeforeUpdate: true,
setState: {
skipsComponentDidUpdateOnNullish: true,
Expand Down

0 comments on commit d686c91

Please sign in to comment.