Skip to content

Commit

Permalink
Compare align wiht shallowequal to avoid unnecessary forceLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Mar 13, 2018
1 parent 8bb45c2 commit b449aba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"babel-runtime": "^6.26.0",
"dom-align": "1.x",
"prop-types": "^15.5.8",
"rc-util": "^4.0.4"
"rc-util": "^4.0.4",
"shallowequal": "^1.0.2"
}
}
3 changes: 2 additions & 1 deletion src/Align.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import align from 'dom-align';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import shallowequal from 'shallowequal';
import isWindow from './isWindow';

function buffer(fn, ms) {
Expand Down Expand Up @@ -59,7 +60,7 @@ class Align extends Component {
const props = this.props;

if (!props.disabled) {
if (prevProps.disabled || prevProps.align !== props.align) {
if (prevProps.disabled || !shallowequal(prevProps.align, props.align)) {
reAlign = true;
} else {
const lastTarget = prevProps.target();
Expand Down

0 comments on commit b449aba

Please sign in to comment.