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

165
Views
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
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!