1

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('******________********______')
   } 
  • 1
    looks like your code works : [codeSandBox](https://codesandbox.io/s/upbeat-bash-fz6rt?fontsize=14&hidenavigation=1&theme=dark) the only difference is that I've added a child to Profiler Component but I think that you avoid to put one in your question for more clarity :-) – antoineso Mar 10 '21 at 16:33

0 Answers0