Answer the question
In order to leave comments, you need to log in
How to connect 2 swiper react so that when you click on a button in one slider, the picture in the second slider also changes?
There is such a code
const [firstSwiper, setFirstSwiper] = useState(null);
const [secondSwiper, setSecondSwiper] = useState(null);
return (
<div className={styles.foto}>
<div className={styles.wrapper}>
<Swiper
modules={[Controller]}
onSwiper={setFirstSwiper}
controller={{ control: secondSwiper }}
navigation
spaceBetween={50}
slidesPerView={1}
>
{card.images.map((item) => (
<SwiperSlide key={item.url}>
<img
src={...}
/>
</SwiperSlide>
))}
</Swiper>
</div>
<div className={styles.container}>
<Swiper
modules={[Controller]}
onSwiper={setSecondSwiper}
controller={{ control: firstSwiper }}
navigation
spaceBetween={50}
slidesPerView={1}
>
{card.images.map((item) => (
<SwiperSlide c key={item.url}>
<img
src={...}
/>
</SwiperSlide>
))}
</Swiper>
</div>
</div>
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question