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

211
Views
When I get to last item of the react carousel, it takes two clicks to center back to the first item

So when im on the last item and i click next it will move to next item but wont move the scrollbar back to the beginning unless if I hit next again but then the index is now on the second item not the first.

const nextSlide = () => {
   if (current === length - 1) {
     setCurrent(0);
     listRef.current.scrollIntoView({
       behaviour: "smooth",
       block: "nearest",
       inline: "center",
     });
   } else {
     setCurrent(current + 1);
     listRef.current.scrollIntoView({
       behaviour: "smooth",
       block: "nearest",
       inline: "center",
     });
   }
 };

here is the codebox: https://codesandbox.io/s/boring-sea-bfds7?file=/src/App.js

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!