Skip to content

Commit

Permalink
Fix shallow comparison of itemsChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin committed Aug 22, 2019
1 parent 65d98b8 commit 3ea5a43
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ImageGallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,17 @@ export default class ImageGallery extends React.Component {
},
};

componentDidMount() {
if (this.props.autoPlay) {
this.play();
}
window.addEventListener('keydown', this._handleKeyDown);
this._onScreenChangeEvent();
}

componentDidUpdate(prevProps, prevState) {
const itemsSizeChanged = prevProps.items.length !== this.props.items.length;
const itemsChanged = prevProps.items !== this.props.items;
const itemsChanged = JSON.stringify(prevProps.items) !== JSON.stringify(this.props.items);
const startIndexUpdated = prevProps.startIndex !== this.props.startIndex;
if (itemsSizeChanged) {
this._handleResize();
Expand All @@ -188,14 +196,6 @@ export default class ImageGallery extends React.Component {
}
}

componentDidMount() {
if (this.props.autoPlay) {
this.play();
}
window.addEventListener('keydown', this._handleKeyDown);
this._onScreenChangeEvent();
}

componentWillUnmount() {
window.removeEventListener('keydown', this._handleKeyDown);

Expand Down

0 comments on commit 3ea5a43

Please sign in to comment.