解决:
You should find this in .../node_modules/react-native-swiper/src/index.js
componentWillReceiveProps (nextProps) {
if (!nextProps.autoplay && this.autoplayTimer) clearTimeout(this.autoplayTimer)
this.setState(this.initState(nextProps, this.props.index !== nextProps.index))
}
plz remove this and try again, it will be run correctly.
原帖:https://github.com/leecade/react-native-swiper/issues/731
我的方法:渲染更新后设置滑动到0
<Swiper
ref="scrollView"
loop = {true}
horizontal={true}
showsHorizontalScrollIndicator={false}
pagingEnabled={true}
>
{this.state.TestPromotionData.map((key, i) => this.renderPromotion(key, i))}
</Swiper>
componentDidUpdate() {
var ScrollView = this.refs.scrollView;
ScrollView.scrollBy(0, false)
}
推荐改用:https://github.com/rilyu/teaset