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

172
Visualizações
How can I make this infinite? I want to move the first element of an array to the last position using React Js

I creating this automatic infinite slider in React Js but it is not infinite. I am thinking that the best way to make it infinite is to move the first element to the end and make that in the setInterval in that way my array is always exchanging positions.

export const Slider = ({ images }) => {
    const [position, setPosition] = useState(0);

    useEffect(() => {
        const interval = setInterval(() => {
            setPosition(prev => prev + 0.1);
        }, 1000);
    }, []);

    const containerVar = {
        hidden: {
            x: 0,
        },
        show: {
            x: -250 * position,
            transition: { repeat: Infinity, duration: 2, ease: 'linear' },
        },
    };
    return (
        <Container
            as={motion.div}
            variants={containerVar}
            initial='hidden'
            animate='show'
        >
            {images.map(({ name, ...imagesData }) => (
                <CardClients key={name} name={name} {...imagesData} />
            ))}
        </Container>
    );
};
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