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

438
Views
Nextjs: create countdown OTP verify

This is my Login.tsx

{!isVerify ? (
    // Login form
) : (
    <Verify data-phoneNumber={form.phoneNumber} data-countryCode={form.countryCode} />
)}

After send mobile with user, I change isVerify to True and <Verify /> component show to user.

And this is my verify:

const runTimer = () => {
        useEffect(() => {
            const interval = setInterval(() => {
                console.log(time);
                setTime(
                    (currentTime) => {
                        if (currentTime > 0) {
                            return currentTime - 1;
                        } else {
                            setResend(false)
                            clearInterval(interval);
                            return currentTime;
                        }
                    }
                );
            }, 1000);
            return () => clearInterval(interval)
        }, [])
}

const runAgain = () => {
    runTimer()
}

return (
    <div>
        {runTimer()}
        <div onClick={(e) => runAgain(e)}>Run Again</div>
    </div>
)   

For first time my timer work fine. but for second time not work! ( if I click on run again )

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!