react-native-swiper v1.6.0
react-native-swiper使用onIndexChanged时
onIndexChanged={index => {changeIndex(index);}}
滑动数据错误
iOS修改:
添加loadMinimal={true}
Android修改index.js文件
UNSAFE_componentWillUpdate(nextProps, nextState) {
// If the index has changed, we notify the parent via the onIndexChanged callback
if (this.state.index !== nextState.index){
this.setState({index:nextState.index})//添加
this.props.onIndexChanged(nextState.index)}
}
//componentDidUpdate修改
componentDidUpdate(prevProps) {
// If autoplay props updated to true, autoplay immediately
if (this.props.autoplay && !prevProps.autoplay) {
this.autoplay()
}
if (this.props.children !== prevProps.children) {
if (this.props.loadMinimal ) {
this.setState({ ...this.props, index:this.state.index })
}
}
}