CommitFlamegraphListItem() — react Function Reference
Architecture documentation for the CommitFlamegraphListItem() function in CommitFlamegraphListItem.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 8159aab7_7fe7_acb7_ac62_f220ff6da653["CommitFlamegraphListItem()"] 6d32cfc6_78ff_92b2_0a33_092cde10d395["CommitFlamegraphListItem.js"] 8159aab7_7fe7_acb7_ac62_f220ff6da653 -->|defined in| 6d32cfc6_78ff_92b2_0a33_092cde10d395 style 8159aab7_7fe7_acb7_ac62_f220ff6da653 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js lines 29–133
function CommitFlamegraphListItem({data, index, style}: Props): React.Node {
const {
chartData,
onElementMouseEnter,
onElementMouseLeave,
scaleX,
selectedChartNode,
selectedChartNodeIndex,
selectFiber,
width,
} = data;
const {renderPathNodes, maxSelfDuration, rows} = chartData;
const {lineHeight} = useContext(SettingsContext);
const handleClick = useCallback(
(event: SyntheticMouseEvent, id: number, name: string) => {
event.stopPropagation();
selectFiber(id, name);
},
[selectFiber],
);
const handleMouseEnter = (nodeData: ChartNodeType) => {
const {id, name} = nodeData;
onElementMouseEnter({id, name});
};
const handleMouseLeave = () => {
onElementMouseLeave();
};
// List items are absolutely positioned using the CSS "top" attribute.
// The "left" value will always be 0.
// Since height is fixed, and width is based on the node's duration,
// We can ignore those values as well.
const top = parseInt(style.top, 10);
const row = rows[index];
const selectedNodeOffset = scaleX(
selectedChartNode !== null ? selectedChartNode.offset : 0,
width,
);
return (
<Fragment>
{row.map(chartNode => {
const {
didRender,
id,
label,
name,
offset,
selfDuration,
treeBaseDuration,
} = chartNode;
const nodeOffset = scaleX(offset, width);
const nodeWidth = scaleX(treeBaseDuration, width);
// Filter out nodes that are too small to see or click.
// This also helps render large trees faster.
if (nodeWidth < barWidthThreshold) {
return null;
}
// Filter out nodes that are outside of the horizontal window.
if (
nodeOffset + nodeWidth < selectedNodeOffset ||
nodeOffset > selectedNodeOffset + width
) {
return null;
}
let color = 'url(#didNotRenderPattern)';
let textColor = 'var(--color-commit-did-not-render-pattern-text)';
if (didRender) {
color = getGradientColor(selfDuration / maxSelfDuration);
textColor = 'var(--color-commit-gradient-text)';
} else if (renderPathNodes.has(id)) {
Domain
Subdomains
Source
Frequently Asked Questions
What does CommitFlamegraphListItem() do?
CommitFlamegraphListItem() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js.
Where is CommitFlamegraphListItem() defined?
CommitFlamegraphListItem() is defined in packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free