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

250
Views
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 answers
Answer question

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 Report
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!