useCommitFilteringAndNavigation.js — react Source File
Architecture documentation for useCommitFilteringAndNavigation.js, a javascript file in the react codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 1d558132_0276_7e48_1a18_611bb9fef088["useCommitFilteringAndNavigation.js"] 315baf50_1028_51ca_a9c1_679c6a17ed98["hooks.js"] 1d558132_0276_7e48_1a18_611bb9fef088 --> 315baf50_1028_51ca_a9c1_679c6a17ed98 98e7cbed_f4b4_9f35_838e_6e7cf3e5edcf["types.js"] 1d558132_0276_7e48_1a18_611bb9fef088 --> 98e7cbed_f4b4_9f35_838e_6e7cf3e5edcf ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 1d558132_0276_7e48_1a18_611bb9fef088 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 6c4f87a5_052e_5ad2_3388_1e4392b92a53["ProfilerContext.js"] 6c4f87a5_052e_5ad2_3388_1e4392b92a53 --> 1d558132_0276_7e48_1a18_611bb9fef088 style 1d558132_0276_7e48_1a18_611bb9fef088 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {useCallback, useMemo, useState} from 'react';
import {useLocalStorage} from '../hooks';
import type {CommitDataFrontend} from './types';
export type CommitFilteringAndNavigation = {
isCommitFilterEnabled: boolean,
setIsCommitFilterEnabled: (value: boolean) => void,
minCommitDuration: number,
setMinCommitDuration: (value: number) => void,
// Selection state
selectedCommitIndex: number | null,
selectCommitIndex: (value: number | null) => void,
// Filtered data
filteredCommitIndices: Array<number>,
selectedFilteredCommitIndex: number | null,
// Navigation
selectNextCommitIndex: () => void,
selectPrevCommitIndex: () => void,
};
export function useCommitFilteringAndNavigation(
commitData: Array<CommitDataFrontend>,
): CommitFilteringAndNavigation {
// Filter settings persisted to localStorage
const [isCommitFilterEnabled, setIsCommitFilterEnabledValue] =
useLocalStorage<boolean>('React::DevTools::isCommitFilterEnabled', false);
const [minCommitDuration, setMinCommitDurationValue] =
useLocalStorage<number>('minCommitDuration', 0);
// Currently selected commit index (in the unfiltered list)
const [selectedCommitIndex, selectCommitIndex] = useState<number | null>(
null,
);
// Reset commit index when commitData changes (e.g., when switching roots).
const [previousCommitData, setPreviousCommitData] =
useState<Array<CommitDataFrontend>>(commitData);
if (previousCommitData !== commitData) {
setPreviousCommitData(commitData);
selectCommitIndex(commitData.length > 0 ? 0 : null);
}
const calculateFilteredIndices = useCallback(
(enabled: boolean, minDuration: number): Array<number> => {
return commitData.reduce((reduced: Array<number>, commitDatum, index) => {
if (!enabled || commitDatum.duration >= minDuration) {
reduced.push(index);
// ... (148 more lines)
Domain
Subdomains
Functions
- CommitFilteringAndNavigation.selectNextCommitIndex()
- CommitFilteringAndNavigation.selectPrevCommitIndex()
- CommitFilteringAndNavigation.setIsCommitFilterEnabled()
- CommitFilteringAndNavigation.setMinCommitDuration()
- adjustSelectionAfterFilterChange()
- filteredCommitIndices()
- selectNextCommitIndex()
- selectPrevCommitIndex()
- selectedFilteredCommitIndex()
- setIsCommitFilterEnabled()
- setMinCommitDuration()
- useCommitFilteringAndNavigation()
Source
Frequently Asked Questions
What does useCommitFilteringAndNavigation.js do?
useCommitFilteringAndNavigation.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in useCommitFilteringAndNavigation.js?
useCommitFilteringAndNavigation.js defines 12 function(s): CommitFilteringAndNavigation.selectNextCommitIndex, CommitFilteringAndNavigation.selectPrevCommitIndex, CommitFilteringAndNavigation.setIsCommitFilterEnabled, CommitFilteringAndNavigation.setMinCommitDuration, adjustSelectionAfterFilterChange, filteredCommitIndices, selectNextCommitIndex, selectPrevCommitIndex, selectedFilteredCommitIndex, setIsCommitFilterEnabled, and 2 more.
What does useCommitFilteringAndNavigation.js depend on?
useCommitFilteringAndNavigation.js imports 3 module(s): hooks.js, react, types.js.
What files import useCommitFilteringAndNavigation.js?
useCommitFilteringAndNavigation.js is imported by 1 file(s): ProfilerContext.js.
Where is useCommitFilteringAndNavigation.js in the architecture?
useCommitFilteringAndNavigation.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Profiler).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free