SnapshotSelector() — react Function Reference
Architecture documentation for the SnapshotSelector() function in SnapshotSelector.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD c2f673f0_766a_7478_cc96_295bf590efaa["SnapshotSelector()"] b350cf53_cbc3_d273_ad6c_5485a91ef713["SnapshotSelector.js"] c2f673f0_766a_7478_cc96_295bf590efaa -->|defined in| b350cf53_cbc3_d273_ad6c_5485a91ef713 style c2f673f0_766a_7478_cc96_295bf590efaa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js lines 23–184
export default function SnapshotSelector(_: Props): React.Node {
const {
rootID,
selectedCommitIndex,
selectCommitIndex,
selectPrevCommitIndex,
selectNextCommitIndex,
filteredCommitIndices,
selectedFilteredCommitIndex,
} = useContext(ProfilerContext);
const {profilerStore} = useContext(StoreContext);
const {commitData} = profilerStore.getDataForRoot(((rootID: any): number));
const totalDurations: Array<number> = [];
const commitTimes: Array<number> = [];
commitData.forEach(commitDatum => {
totalDurations.push(
commitDatum.duration +
(commitDatum.effectDuration || 0) +
(commitDatum.passiveEffectDuration || 0),
);
commitTimes.push(commitDatum.timestamp);
});
const numFilteredCommits = filteredCommitIndices.length;
let label = null;
if (numFilteredCommits > 0) {
// $FlowFixMe[missing-local-annot]
const handleCommitInputChange = event => {
const value = parseInt(event.currentTarget.value, 10);
if (!isNaN(value)) {
const filteredIndex = Math.min(
Math.max(value - 1, 0),
// Snashots are shown to the user as 1-based
// but the indices within the profiler data array ar 0-based.
numFilteredCommits - 1,
);
selectCommitIndex(filteredCommitIndices[filteredIndex]);
}
};
// $FlowFixMe[missing-local-annot]
const handleClick = event => {
event.currentTarget.select();
};
// $FlowFixMe[missing-local-annot]
const handleKeyDown = event => {
switch (event.key) {
case 'ArrowDown':
selectPrevCommitIndex();
event.stopPropagation();
break;
case 'ArrowUp':
selectNextCommitIndex();
event.stopPropagation();
break;
default:
break;
}
};
const input = (
<input
className={styles.Input}
data-testname="SnapshotSelector-Input"
type="text"
inputMode="numeric"
pattern="[0-9]*"
value={
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
selectedFilteredCommitIndex + 1
}
size={`${numFilteredCommits}`.length}
onChange={handleCommitInputChange}
onClick={handleClick}
onKeyDown={handleKeyDown}
/>
Domain
Subdomains
Source
Frequently Asked Questions
What does SnapshotSelector() do?
SnapshotSelector() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js.
Where is SnapshotSelector() defined?
SnapshotSelector() is defined in packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js at line 23.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free