Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda