Skip to content

Commit

Permalink
Merge pull request #111 from lryta/master
Browse files Browse the repository at this point in the history
Fix crash when this.props.images.length - 1 < this.state.currentImage

Thanks @lryta
  • Loading branch information
benhowell authored Mar 9, 2019
2 parents 5b80629 + eb02b4a commit 7cf2d2d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Gallery extends Component {
}

componentWillReceiveProps (np) {
if (this.state.currentImage > np.images.length - 1) {
this.setState({currentImage: np.images.length - 1});
}
if(this.state.images != np.images || this.props.maxRows != np.maxRows){
this.setState({
images: np.images,
Expand Down

0 comments on commit 7cf2d2d

Please sign in to comment.