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 0a17404 commit e7106c4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 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,18 @@ 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)
);
}

return true;
}

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

0 comments on commit e7106c4

Please sign in to comment.