Open kaloncheung124 opened 7 years ago
I think it's due to the currentPage default prop. If I haven't set the currentPage
prop, whenever componentWillReceiveProps
gets called, it still receives a currentPage
prop with a value of 0. This sets this.state.currentPage
to 0 whenever the carousel is re-rendered. Perhaps remove this from the default props and add some checking for undefined?
In my app, we have a screen component that contains the carousel and a list of data. We wish to use the carousel onPageHandler to select between different sources for the data. However, when we try to change the screen component state within onPageChange, the carousel pauses and then scrolls back to the first element.
Here is the stripped down code for our home screen with the carousel within it:
Any help would be greatly appreciated!