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

241
Vistas
How to tell if a React functional component has been rendered in code?

I am trying to add some logging to see how much time it takes to render a functional component in React. The tricky part to me is how to actually tell when the component has been rendered. By "rendered", it means the user can see it in the front end (all parts in that component should be displayed). I am trying to use useEffect to achieve this, as it can tell when the component is mounted.

The code is something like below:

function showComponent() {
   console.log('start rendering....start timer');
   console.log(new Date().getTime());
   
   setStoreViewState('foobar');
}

observer(function Component() {
   React.useEffect(() => {
     console.log('rendering complete....stop timer');
     console.log(new Date().getTime());
 }, []);
   ......
   const thingsToShow = getStoreViewState();
   return (<div>{thingsToShow}</div>)
}

I am wondering if this is an accurate way to achieve this. Thanks!

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

0

According to the docs, the useEffect with no dependency means that it has finished rendering.

https://reactjs.org/docs/hooks-effect.html

Also, don’t forget that React defers running useEffect until after the browser has painted, so doing extra work is less of a problem.

The quote above is from the docs.

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