tezvyn:

How do React Profiler flame and ranked charts pinpoint bottlenecks?

AI-drafted, machine-checkedSource: legacy.reactjs.orgintermediate
WHAT IT TESTS

Distinguishing flame chart subtree cost from ranked chart self-time.

ANSWER OUTLINE

Flame chart width and color show duration with children; ranked chart sorts by self-time to surface the top component.

RED FLAG

Calling them identical.

WHAT THIS TESTS: This question evaluates whether you understand the two primary visualization modes in the React DevTools Profiler and how to use them together to diagnose render performance. It specifically checks if you know the difference between inclusive time, which includes children, and self time, which does not, and whether you can map those metrics to the correct visual representation.

A GOOD ANSWER COVERS: A strong answer explains that the flame chart represents a single commit as a stacked bar chart of the component tree, where the width of each bar indicates how long that component and its children took to render, and the color indicates how much time was spent as part of the current commit, with yellow meaning slower and blue meaning faster. It notes that gray bars represent components that did not render during that commit. The answer then contrasts this with the ranked chart, which flattens the same commit into a sorted list of components ordered by self-render time, making it easy to spot the single most expensive component without the noise of its descendants. The candidate should describe a workflow: start with the flame chart to identify which subtree is expensive, then switch to the ranked chart to pinpoint the exact component within that subtree that is consuming the most time on its own. Mentioning that clicking a component reveals props, state, and the reason for re-render in the right panel adds depth.

COMMON WRONG ANSWERS: A red flag is claiming that both charts show the same information or that the ranked chart preserves the tree structure. Another mistake is saying that flame chart width represents self-time rather than inclusive time. Candidates who ignore the significance of color coding or who fail to mention that gray bars did not render in the commit reveal a lack of hands-on profiling experience. Saying you would use console logs instead of the profiler is also a negative signal at the senior level.

LIKELY FOLLOW-UPS: The interviewer may ask how you would use the component chart to track a single component across multiple commits, or how you would interpret the commit bar chart at the top to select the slowest commit. They might also ask about the production profiling bundle, how to enable it, or how interactions help attribute commits to specific user events. Expect a question about memoization strategies once you have identified the expensive component.

ONE CONCRETE EXAMPLE: Imagine a commit where a Router component takes 18.4 milliseconds. In the flame chart, you see Router is wide and yellow, with two wide children named Nav at 8.4 milliseconds and Route at 7.9 milliseconds. You click into Nav and notice it re-rendered because a context value changed. To confirm Nav itself is the problem rather than its children, you open the ranked chart and see Nav at the top with a high self-time, while its children have low self-times. This tells you to wrap Nav in React.memo or split its context subscription rather than optimizing its children.

Read the original → legacy.reactjs.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.