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

128
Views
React Native: Getting "Maximum update depth exceeded error"

I'm getting maximum update depth exceeded error when i try to start countdown in my React Native app. Initially when i pass a stringed date to the "expirydate" variable, it works fine, and my countdown timer works fine. However, I'm building the app so that it fetches a delivery date and time from firebase and I need to use that to pass that to the "expirydate" variable, so the driver can be in sync with the delivery countdown. When I pass the fetched date, that's when i get the error.

Here's the code when I pass a normal stringed date πŸ‘‡

const start_timer = () => {
setTimerStarted(true);
var date = moment().format("YYYY-MM-DD hh:mm:ss");
//Getting the current date-time with required formate and UTC

var expirydate =
  '2021-12-04 08:40:45';
//Let suppose we have to show the countdown for above date-time

var diffr = moment.duration(moment(expirydate).diff(moment(date)));
//difference of the expiry date-time given and current date-time
var hours = parseInt(diffr.asHours());
var minutes = parseInt(diffr.minutes());
var seconds = parseInt(diffr.seconds());
var d = hours * 60 * 60 + minutes * 60 + seconds;
//converting in seconds
setTotalDuration(d);
//Settign up the duration of countdown in seconds to re-render

};

And here's my code when i pass the fetched date πŸ‘‡

const start_timer = () => {
setTimerStarted(true);
var date = moment().format("YYYY-MM-DD hh:mm:ss");
//Getting the current date-time with required formate and UTC

var expirydate = details.date;
//Let suppose we have to show the countdown for above date-time

var diffr = moment.duration(moment(expirydate).diff(moment(date)));
//difference of the expiry date-time given and current date-time
var hours = parseInt(diffr.asHours());
var minutes = parseInt(diffr.minutes());
var seconds = parseInt(diffr.seconds());
var d = hours * 60 * 60 + minutes * 60 + seconds;
//converting in seconds
setTotalDuration(d);
//Settign up the duration of countdown in seconds to re-render

};

And here's how I'm starting the timer πŸ‘‡

<TouchableOpacity onPress={() => start_timer()}>
        <>
          <LottieView
            style={{ alignSelf: "center", height: 40 }}
            source={require("../../../assets/animations/timer.json")}
            autoPlay={true}
            speed={2}
            loop={true}
          />
          <Text style={{ color: "rgb(124, 90, 15)" }}>Start Timer</Text>
        </>
      </TouchableOpacity>

My gut tells me that it's probably an issue with momentπŸ€”.. I just am not sure.

Just to be sure, when I console.log(details.date), it returns this format of date "December 4th, 2021 19:25PM"... That's why I don't think it's an issue with fetched date, or I'm not sure. Any help please?

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!