draw() — react Function Reference
Architecture documentation for the draw() function in ReactMeasuresView.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 7898c7fb_c4a8_d5bd_a78e_878f99079dcc["draw()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5["ReactMeasuresView"] 7898c7fb_c4a8_d5bd_a78e_878f99079dcc -->|defined in| ef3af242_6989_01f2_141b_b5ae3fce4bc5 af21523b_b0f3_6208_d571_52ad547b495c["_drawSingleReactMeasure()"] 7898c7fb_c4a8_d5bd_a78e_878f99079dcc -->|calls| af21523b_b0f3_6208_d571_52ad547b495c 6fe722ba_3051_6ecf_abe3_62a190c3ad25["positioningScaleFactor()"] 7898c7fb_c4a8_d5bd_a78e_878f99079dcc -->|calls| 6fe722ba_3051_6ecf_abe3_62a190c3ad25 1d4e7b93_85d0_def6_42c9_e20824e49731["drawText()"] 7898c7fb_c4a8_d5bd_a78e_878f99079dcc -->|calls| 1d4e7b93_85d0_def6_42c9_e20824e49731 style 7898c7fb_c4a8_d5bd_a78e_878f99079dcc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js lines 205–298
draw(context: CanvasRenderingContext2D): void {
const {frame, _hoveredMeasure, _lanesToRender, _profilerData, visibleArea} =
this;
context.fillStyle = COLORS.PRIORITY_BACKGROUND;
context.fillRect(
visibleArea.origin.x,
visibleArea.origin.y,
visibleArea.size.width,
visibleArea.size.height,
);
const scaleFactor = positioningScaleFactor(
this._intrinsicSize.width,
frame,
);
for (let i = 0; i < _lanesToRender.length; i++) {
const lane = _lanesToRender[i];
const baseY = frame.origin.y + i * REACT_LANE_HEIGHT;
const measuresForLane = _profilerData.laneToReactMeasureMap.get(lane);
if (!measuresForLane) {
throw new Error(
'No measures found for a React lane! This is a bug in this profiler tool. Please file an issue.',
);
}
// Render lane labels
const label = _profilerData.laneToLabelMap.get(lane);
if (label == null) {
console.warn(`Could not find label for lane ${lane}.`);
} else {
const labelRect = {
origin: {
x: visibleArea.origin.x,
y: baseY,
},
size: {
width: visibleArea.size.width,
height: REACT_LANE_HEIGHT,
},
};
drawText(label, context, labelRect, visibleArea, {
fillStyle: COLORS.TEXT_DIM_COLOR,
});
}
// Draw measures
for (let j = 0; j < measuresForLane.length; j++) {
const measure = measuresForLane[j];
const showHoverHighlight = _hoveredMeasure === measure;
const showGroupHighlight =
!!_hoveredMeasure && _hoveredMeasure.batchUID === measure.batchUID;
this._drawSingleReactMeasure(
context,
visibleArea,
measure,
measuresForLane[j + 1] || null,
baseY,
scaleFactor,
showGroupHighlight,
showHoverHighlight,
);
}
// Render bottom border
const borderFrame: Rect = {
origin: {
x: frame.origin.x,
y: frame.origin.y + (i + 1) * REACT_LANE_HEIGHT - BORDER_SIZE,
},
size: {
width: frame.size.width,
height: BORDER_SIZE,
},
};
if (rectIntersectsRect(borderFrame, visibleArea)) {
const borderDrawableRect = intersectionOfRects(
Domain
Subdomains
Source
Frequently Asked Questions
What does draw() do?
draw() is a function in the react codebase, defined in packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js.
Where is draw() defined?
draw() is defined in packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js at line 205.
What does draw() call?
draw() calls 3 function(s): _drawSingleReactMeasure, drawText, positioningScaleFactor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free