Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
Advice on designing lifecycle method

i'd like to design a function that is not triggered by a button click, not onmount, not on unmount but on given set 'times' like below:

function () {
 if this time comes: do this
 also if this comes: do this
 and if this time comes: do this
 any time that is not one of the times above: do nothing
}

i currently, the options i know i have are using the useEffect hook, or setInterval, but am not sure if they can work, i dont know how to do it either. kindly suggest on how i can achieve this

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

setInterval is great for executing a function at regular intervals. for instance:

function sayHelloWorld() {
    console.log('Hello, World!');
}

// interval in milliseconds --> 1000ms = 1 sec...
const sayOverAndOver = setInterval(sayHelloWorld, 1000);

After 1 second and each second thereafter, the console will log 'Hello, World!'

Some good resources with great explainers on setInterval, etc. are W3Schools, GeeksForGeeks, and Mozilla MDN. I tried to link to them here, but the text editor on here is buggy.

Cheers!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda