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

176
Views
How do I fix React rendering issues?

I have a very simple component that fetches data and do some easy computation. Every time the page refreshes the component renders, the value will change. I have also tried clearing the cache thinking it might be an issue but it didn't solve the problem. Thank you for your help!

I have tried removing and I get a warning with a message suggesting to add difference but even without it, it still behaves the same on every single render. I use difference value like this

I have put the code on Sandbox to make easier to debug. Same problem still occurs on every other page refresh.

https://codesandbox.io/s/agitated-cdn-q3gju?file=/src/Card.js

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

0

Each state change generates the component rendering. You are listening to the "difference" variable change and changing it again with setDifference, creating a loop.

This

useEffect(()=>{
   setState(something)
},[state])

Use

useEffect(()=>{
   setState(something)
},[])
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!