Pranav Sharma
Pranav Sharma

Reputation: 59

Why doesn't React Profiler API log anything?

I am trying to use React profiler but it only works when I my onRender method is like this.

<Profiler id="BrowseCategories" onRender={console.log('hi')} }></Profiler>

It doesn't log anything when I do this

<Profiler id="BrowseCategories" onRender={callback} }></Profiler>

This is my callback function

  const callback = (id, phase, actualTime, baseTime, startTime, commitTime) => {
     console.log('******________********______')
     console.log(`${id}'s ${phase} phase:`);
     console.log(`Actual time: ${actualTime}`);
     console.log(`Base time: ${baseTime}`);
     console.log(`Start time: ${startTime}`);
     console.log(`Commit time: ${commitTime}`);
     console.log('******________********______')
   } 

Upvotes: 1

Views: 229

Answers (0)

Related Questions