Skip to content

Commit

Permalink
fix #452 (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjfkai authored and Sarah Meyer committed Dec 6, 2018
1 parent 2efb0d3 commit f2c2623
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Expand Up @@ -105,12 +105,12 @@ export default class Carousel extends React.Component {
componentWillReceiveProps(nextProps) {
const slideCount = getValidChildren(nextProps.children).length;
const slideCountChanged = slideCount !== this.state.slideCount;
this.setState({
this.setState(prevState => ({
slideCount,
currentSlide: slideCountChanged
? nextProps.slideIndex
: this.state.currentSlide
});
: prevState.currentSlide
}));

if (slideCount <= this.state.currentSlide) {
this.goToSlide(Math.max(slideCount - 1, 0), nextProps);
Expand Down

0 comments on commit f2c2623

Please sign in to comment.