Skip to content

Commit

Permalink
[enzyme-adapter-react-16] [new] add shouldUpdateComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
sstern6 authored and ljharb committed Jan 15, 2019
1 parent 31c33e5 commit 6e7abd0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
StrictMode,
} from 'react-is';
import { EnzymeAdapter } from 'enzyme';
import { typeOfNode } from 'enzyme/build/Utils';
import { typeOfNode, shallowEqual } from 'enzyme/build/Utils';
import {
displayNameOfNode,
elementToTree as utilElementToTree,
Expand Down Expand Up @@ -701,6 +701,16 @@ class ReactSixteenAdapter extends EnzymeAdapter {
return isElement(element);
}

shouldUpdateComponent(prevProps, root) {
const instance = root.instance();
if (instance !== null) {
const { updater, props } = instance;
return (
updater._renderer._newState !== null || !shallowEqual(prevProps, props)
);
}
}

isValidElementType(object) {
return !!object && isValidElementType(object);
}
Expand Down

0 comments on commit 6e7abd0

Please sign in to comment.