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

178
Views
cómo arreglar la aplicación de temporizador fn de incrementos en reaccionar

hola dev's iam tring para construir la aplicación de reacción pomodoro del temporizador mi problema es cuando comienzo a llamar a la función que incrementa el temporizador con setInterval devuelve 0 y 1 y repite 0 y 1 No más de 0 y 1

mi código es:

 import React, { useRef, useState } from "react"; import Timer from "./Timer"; import styles from "../css/pomodoro.module.css"; const Pomodoro = () => { const [start, setStart] = useState(false); const [intervalRef, setIntervalRef] = useState(0); const [cycles, setCycles] = useState(0); const [seconds, setSeconds] = useState(0); const [minutes, setMinutes] = useState(0); const startTimer = () => { return setInterval(() => { seconds <= 59 ? setSeconds(seconds + 1) : setSeconds(0); }, 1000); }; const stopTimer = () => { clearInterval(intervalRef); }; function handleStartPomodoro() { setStart(!start); if (start === false) { setIntervalRef(startTimer()); startTimer(); console.log("start"); } if (start === true) { stopTimer(); console.log("stop"); } } return ( <div className={styles["app-wrapper"]}> <Timer seconds={seconds} minutes={minutes} /> <div className={styles["buttons-wrapper"]}> <button type="button" onClick={() => handleStartPomodoro()}> Start </button> <button type="button"> reset</button> </div> </div> ); }; export default Pomodoro;
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!