leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.4k stars 2.34k forks source link

Maximum update depth exceeded #968

Open iosLongFeng opened 5 years ago

iosLongFeng commented 5 years ago

andriod

Version

Which versions are you using:

the method setState: scrollBy = (index, animated = true) => { if (this.internals.isScrolling || this.state.total < 2) return const state = this.state const diff = (this.props.loop ? 1 : 0) + index + this.state.index let x = 0 let y = 0 if (state.dir === 'x') x = diff state.width if (state.dir === 'y') y = diff state.height

if (Platform.OS !== 'ios') {
  this.scrollView && this.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff)
} else {
  this.scrollView && this.scrollView.scrollTo({ x, y, animated })
}

// update scroll state
this.internals.isScrolling = true
this.setState({
  autoplayEnd: false
})

// trigger onScrollEnd manually in android
if (!animated || Platform.OS !== 'ios') {
  setImmediate(() => {
    this.onScrollEnd({
      nativeEvent: {
        position: diff
      }
    })
  })
}

}

case Exception: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

retyui commented 5 years ago

This repo dead: https://github.com/leecade/react-native-swiper/issues/713

fabOnReact commented 5 years ago

I read now .. so bad