React · Senior · Question 20 of 75
What's the most accurate way to find which components are slow during interaction?
- ✓Correct answer: Record a profile in the React DevTools Profiler and the browser's Performance panel
- 2Wrap all components in
memoand see if it gets faster - 3Log
console.timein every component in the production build
Explanation
The Profiler shows which components rendered, how long it took and why (enable "Record why each component rendered"). The Performance panel shows long tasks, layout and paint. Optimizing blindly leads to unnecessary complexity. For metrics in code there's <Profiler onRender>.