ReactMeasuresView Class — react Architecture
Architecture documentation for the ReactMeasuresView class in ReactMeasuresView.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD ef3af242_6989_01f2_141b_b5ae3fce4bc5["ReactMeasuresView"] 7a7af6eb_0683_8d73_95cc_81cc7b37dc33["ReactMeasuresView.js"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|defined in| 7a7af6eb_0683_8d73_95cc_81cc7b37dc33 832c0ddc_1576_8235_3ea4_b4ccdd46a619["constructor()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 832c0ddc_1576_8235_3ea4_b4ccdd46a619 2b4fe3d4_cdf8_ce6f_170c_b5212ee38e40["_performPreflightComputations()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 2b4fe3d4_cdf8_ce6f_170c_b5212ee38e40 5e7ee3c7_c73c_60b9_b3f2_5b638e9e977c["desiredSize()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 5e7ee3c7_c73c_60b9_b3f2_5b638e9e977c 23622c10_e7c0_3fee_4842_41275364b0b6["setHoveredMeasure()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 23622c10_e7c0_3fee_4842_41275364b0b6 af21523b_b0f3_6208_d571_52ad547b495c["_drawSingleReactMeasure()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| af21523b_b0f3_6208_d571_52ad547b495c 7898c7fb_c4a8_d5bd_a78e_878f99079dcc["draw()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 7898c7fb_c4a8_d5bd_a78e_878f99079dcc 81aa7ce8_ea82_55e8_c236_fdad49700b6a["_handleMouseMove()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 81aa7ce8_ea82_55e8_c236_fdad49700b6a 97de3d65_b18d_2369_7ff0_ed91c54a1633["handleInteraction()"] ef3af242_6989_01f2_141b_b5ae3fce4bc5 -->|method| 97de3d65_b18d_2369_7ff0_ed91c54a1633
Relationship Graph
Source Code
packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js lines 40–370
export class ReactMeasuresView extends View {
_intrinsicSize: IntrinsicSize;
_lanesToRender: ReactLane[];
_profilerData: TimelineData;
_hoveredMeasure: ReactMeasure | null = null;
onHover: ((measure: ReactMeasure | null) => void) | null = null;
constructor(surface: Surface, frame: Rect, profilerData: TimelineData) {
super(surface, frame);
this._profilerData = profilerData;
this._performPreflightComputations();
}
_performPreflightComputations() {
this._lanesToRender = [];
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const [lane, measuresForLane] of this._profilerData
.laneToReactMeasureMap) {
// Only show lanes with measures
if (measuresForLane.length > 0) {
this._lanesToRender.push(lane);
}
}
this._intrinsicSize = {
width: this._profilerData.duration,
height: this._lanesToRender.length * REACT_LANE_HEIGHT,
hideScrollBarIfLessThanHeight: REACT_LANE_HEIGHT,
maxInitialHeight: MAX_ROWS_TO_SHOW_INITIALLY * REACT_LANE_HEIGHT,
};
}
desiredSize(): IntrinsicSize {
return this._intrinsicSize;
}
setHoveredMeasure(hoveredMeasure: ReactMeasure | null) {
if (this._hoveredMeasure === hoveredMeasure) {
return;
}
this._hoveredMeasure = hoveredMeasure;
this.setNeedsDisplay();
}
/**
* Draw a single `ReactMeasure` as a bar in the canvas.
*/
_drawSingleReactMeasure(
context: CanvasRenderingContext2D,
rect: Rect,
measure: ReactMeasure,
nextMeasure: ReactMeasure | null,
baseY: number,
scaleFactor: number,
showGroupHighlight: boolean,
showHoverHighlight: boolean,
): void {
const {frame, visibleArea} = this;
const {timestamp, type, duration} = measure;
let fillStyle = null;
let hoveredFillStyle = null;
let groupSelectedFillStyle = null;
let textFillStyle = null;
// We could change the max to 0 and just skip over rendering anything that small,
// but this has the effect of making the chart look very empty when zoomed out.
// So long as perf is okay- it might be best to err on the side of showing things.
const width = durationToWidth(duration, scaleFactor);
if (width <= 0) {
return; // Too small to render at this zoom level
}
const x = timestampToPosition(timestamp, scaleFactor, frame);
const measureRect: Rect = {
origin: {x, y: baseY},
size: {width, height: REACT_MEASURE_HEIGHT},
};
if (!rectIntersectsRect(measureRect, rect)) {
Domain
Source
Frequently Asked Questions
What is the ReactMeasuresView class?
ReactMeasuresView is a class in the react codebase, defined in packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js.
Where is ReactMeasuresView defined?
ReactMeasuresView is defined in packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free