leecade / leecade/react-native-swiper
Maximum update depth exceeded
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
andriod
Version
Which versions are you using:
- 1.5.14
- 0.55.3
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue on Android with react-native-swiper 1.5.14 and React Native 0.55.3, starting from the scrollBy method shown in the report. Trace its setState call and the manually triggered onScrollEnd path to identify the repeated update. Done means the reported navigation case no longer raises “Maximum update depth exceeded”.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100