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

88
Views
React change DOM every X seconds

I'm trying to render some cards with different content every 10 seconds, I first fetch the data from the API and then render the first set of data on cards and what I want to do is change the cards content every 10 seconds

For the moment I'm using this:


    const [cards, setCards] = useState<[]>([])

    useEffect(() => {

     props.data.map( (data: any, i: any) => 

          setTimeout(() => {
            setCards(data)
          }, i * 10000)
     )

    }, [cards])

    return (
        <Wrapper>
            <h1>Hello World!</h1>
            <Hero img={bg} />
            <Cards cards={cards} />
        </Wrapper>
    )

That's currently not working, what can I do to make it work correctly ? My final result is every 10 seconds change the content (I will implement some animations too)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solution

I just removed cards from my useEffect hook and used an empty array instead.. Working fine.

about 4 years ago · Juan Pablo Isaza Report
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!