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

234
Views
requestAnimationFrame dentro de la instrucción if conduce a una marca de tiempo indefinida - fuera de 'si' funciona

Estoy usando el siguiente formulario en React

 <form onSubmit={e => {HandleSubmit(e)}}> <div ref={textArea} className="enclosing-divs"> <label className="form-label" htmlFor="message">Message:</label> <textarea className="input-field" style={{ height: "160px", paddingTop: "2px", resize: "none" }} id="message" required /> </div> <button className="submit-button" type="submit"></button> </form>

Al enviar el formulario, quiero que el área de texto (que asigné a una referencia) desaparezca después de que hayan pasado 4 segundos con esta función que estoy llamando arriba:

 function sendEmailAnimation(now) { if (now >= 4000) { textArea.current.style.display = "none"} if (now <= 10000) { requestAnimationFrame(sendEmailAnimation)} } function HandleSubmit(event) { event.preventDefault() sendEmailAnimation()}

PROBLEMA: el código anterior no funciona, PERO si elimino la declaración if para requestAnimationFrame (sendEmailAnimation) para que siempre se ejecute ENTONCES funciona, pero luego tendría un ciclo interminable. Con la declaración if, solo sé que de alguna manera la marca de tiempo no funciona como debería y permanece "indefinida", simplemente no tengo idea de por qué. ¡Gracias por cualquier apoyo!

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!