When using Swiper React + loop, onSlideChange is called twice sometimes. #6260
-
Is that a bug (I guess so)? Is it already reported? Suppose that I have 3 slides A, B and C; and that I swipe always to the right. The callback A → B → C → A → A/B As you can see, the callback is called twice after successfully looping. Is there a workaround? BTW, it's the same with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I fixed it by using The API is really confusing sometimes. It looks like public API as mixed with implementation details, it's really hard to understand what is relevant and what is not. |
Beta Was this translation helpful? Give feedback.
-
I agree that const [currentSlideIndex, setCurrentSlideIndex] = useState(initialSlideIndex);
return (
<Swiper
onTransitionEnd={({ activeIndex }) => {
setCurrentSlideIndex(activeIndex);
}}
></Swiper>
); |
Beta Was this translation helpful? Give feedback.
I fixed it by using
onRealIndexChange
.The API is really confusing sometimes. It looks like public API as mixed with implementation details, it's really hard to understand what is relevant and what is not.