diff --git a/src/index.js b/src/index.js index b2d9f8c..9e4102b 100644 --- a/src/index.js +++ b/src/index.js @@ -85,6 +85,12 @@ export default class Swiper extends Component { }); } + componentWillReceiveProps(nextProps) { + if (nextProps.index !== this.props.index) { + this.goToPage(nextProps.index); + } + } + goToPage(pageNumber) { // Don't scroll outside the bounds of the screens pageNumber = Math.max(0, Math.min(pageNumber, this.props.children.length - 1));