Home / File/ ComponentSearchInput.js — react Source File

ComponentSearchInput.js — react Source File

Architecture documentation for ComponentSearchInput.js, a javascript file in the react codebase. 3 imports, 1 dependents.

File javascript BabelCompiler Validation 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6["ComponentSearchInput.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  f76d4acf_77a2_5398_0548_17d4d0a6039b["SearchInput"]
  ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6 --> f76d4acf_77a2_5398_0548_17d4d0a6039b
  a185f695_5af9_82f0_a43a_ac143541224e["TreeContext"]
  ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6 --> a185f695_5af9_82f0_a43a_ac143541224e
  80ad5569_a221_98e5_daec_ede1bea33ee0["Tree.js"]
  80ad5569_a221_98e5_daec_ede1bea33ee0 --> ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6
  style ad6b058b_c5bb_8fa4_9174_b36bde9c7ec6 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 * as React from 'react';
import {useState, useContext, useCallback} from 'react';

import SearchInput from 'react-devtools-shared/src/devtools/views/SearchInput';
import {
  TreeDispatcherContext,
  TreeStateContext,
} from 'react-devtools-shared/src/devtools/views/Components/TreeContext';

export default function ComponentSearchInput(): React.Node {
  const [localSearchQuery, setLocalSearchQuery] = useState('');
  const {searchIndex, searchResults} = useContext(TreeStateContext);
  const transitionDispatch = useContext(TreeDispatcherContext);

  const search = useCallback(
    (text: string) => {
      setLocalSearchQuery(text);
      transitionDispatch({type: 'SET_SEARCH_TEXT', payload: text});
    },
    [setLocalSearchQuery, transitionDispatch],
  );
  const goToNextResult = useCallback(
    () => transitionDispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}),
    [transitionDispatch],
  );
  const goToPreviousResult = useCallback(
    () => transitionDispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'}),
    [transitionDispatch],
  );

  return (
    <SearchInput
      goToNextResult={goToNextResult}
      goToPreviousResult={goToPreviousResult}
      placeholder="Search (text or /regex/)"
      search={search}
      searchIndex={searchIndex}
      searchResultsCount={searchResults.length}
      searchText={localSearchQuery}
      testName="ComponentSearchInput"
    />
  );
}

Domain

Subdomains

Dependencies

  • SearchInput
  • TreeContext
  • react

Frequently Asked Questions

What does ComponentSearchInput.js do?
ComponentSearchInput.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 ComponentSearchInput.js?
ComponentSearchInput.js defines 1 function(s): ComponentSearchInput.
What does ComponentSearchInput.js depend on?
ComponentSearchInput.js imports 3 module(s): SearchInput, TreeContext, react.
What files import ComponentSearchInput.js?
ComponentSearchInput.js is imported by 1 file(s): Tree.js.
Where is ComponentSearchInput.js in the architecture?
ComponentSearchInput.js is located at packages/react-devtools-shared/src/devtools/views/Components/ComponentSearchInput.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free