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

117
Views
My interval use started state in request to api

I have problem. When i asked backend every 1 minutes he used my started state.for example I change in select startDate on 10.22.2021 .He used my startDate 22.11.2021.When i refresh page onChange in DataPicker or click button Synchronize everything works(startDate = 10.22.2021) this is exactly my problem

my code

const [startDate, setStartDate] = useState(new Date());    
    
useEffect(() => {
    const interval = setInterval(() => {
              //this is important line
              console.log(startDate); //startDate = DateNow i want 10.22.2021
              SetRaport();
            }, 6000);
            return () => {
              clearInterval(interval);
            };
          }, []);

  }, []);

return(
 <StyledDatePicker selected={startDate} onChange={(date) => setStartDate(date)} />
   <Paragraph onClick={() => SetRaport()} style={{ fontWeight: 600 }}>SYNCHRONIZE</Paragraph>

)
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!