Coding task · JavaScript and React course · Module 9: Modern React Hooks
Practice: React Profiler
<Profiler id="name" onRender={callback}> wraps the measured part of the tree. React calls callback(id, phase, actualDuration, baseDuration, startTime, commitTime) after every render of that part.
Task
The TelemetryChart renders hundreds of bars, and the button adds more. Measure its renders with the Profiler component: ___BLANK1___ is the third parameter of the callback, the render time in milliseconds (the name is already used in the function body), ___BLANK2___ is the React component that measures the renders of its subtree, and ___BLANK3___ is the function passed to its onRender attribute. After mounting, an entry with the mount phase should appear in the console, and after clicking the button an entry with the update phase.