Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Swiper js and React: How to pass React state when swiping left or right to prev/next slide

I am using Swiper js for my React slider.

I'am looping over an Object and return the Swiper slides.

I have some (filter) buttons as swiper slides, to filter content when selecting/clicking a button (by passing React state).

The active slide (which gets css class swiper-slide-active by the swiper api) should always be centered.

That's working fine from the api with the following props:

centeredSlides and slideToClickedSlide

But when I 'swipe' the slides to left or right, the swiper active slide get centered, but my other logic on the selected button data-active={true} is now not in sync with swipers active slide.

How to fix this?

Here is the CodeSandbox, with an example what I have so far.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!