Home / File/ TimelineSearchInput.js — react Source File

TimelineSearchInput.js — react Source File

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

File javascript BabelCompiler Validation 5 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  e3efee68_a282_ee12_670e_539a11c16f99["TimelineSearchInput.js"]
  7b213c28_1e91_ab50_3fbc_02eaee967af5["TimelineContext.js"]
  e3efee68_a282_ee12_670e_539a11c16f99 --> 7b213c28_1e91_ab50_3fbc_02eaee967af5
  f222957d_5161_94da_3126_e94f7f8ded93["TimelineSearchContext.js"]
  e3efee68_a282_ee12_670e_539a11c16f99 --> f222957d_5161_94da_3126_e94f7f8ded93
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  e3efee68_a282_ee12_670e_539a11c16f99 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  4d0c4ccc_5970_e7f9_458f_15f0290099b1["react-dom"]
  e3efee68_a282_ee12_670e_539a11c16f99 --> 4d0c4ccc_5970_e7f9_458f_15f0290099b1
  f76d4acf_77a2_5398_0548_17d4d0a6039b["SearchInput"]
  e3efee68_a282_ee12_670e_539a11c16f99 --> f76d4acf_77a2_5398_0548_17d4d0a6039b
  7fd04d1f_8e14_be78_275b_49d4237a927b["Timeline.js"]
  7fd04d1f_8e14_be78_275b_49d4237a927b --> e3efee68_a282_ee12_670e_539a11c16f99
  style e3efee68_a282_ee12_670e_539a11c16f99 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 {useContext} from 'react';
import {createPortal} from 'react-dom';
import SearchInput from 'react-devtools-shared/src/devtools/views/SearchInput';
import {TimelineContext} from './TimelineContext';
import {TimelineSearchContext} from './TimelineSearchContext';

type Props = {};

export default function TimelineSearchInput(props: Props): React.Node {
  const {searchInputContainerRef} = useContext(TimelineContext);
  const {dispatch, searchIndex, searchResults, searchText} = useContext(
    TimelineSearchContext,
  );

  if (searchInputContainerRef.current === null) {
    return null;
  }

  const search = (text: string) =>
    dispatch({type: 'SET_SEARCH_TEXT', payload: text});
  const goToNextResult = () => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'});
  const goToPreviousResult = () =>
    dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'});

  return createPortal(
    <SearchInput
      goToNextResult={goToNextResult}
      goToPreviousResult={goToPreviousResult}
      placeholder="Search components by name"
      search={search}
      searchIndex={searchIndex}
      searchResultsCount={searchResults.length}
      searchText={searchText}
    />,
    searchInputContainerRef.current,
  );
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does TimelineSearchInput.js do?
TimelineSearchInput.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 TimelineSearchInput.js?
TimelineSearchInput.js defines 1 function(s): TimelineSearchInput.
What does TimelineSearchInput.js depend on?
TimelineSearchInput.js imports 5 module(s): SearchInput, TimelineContext.js, TimelineSearchContext.js, react, react-dom.
What files import TimelineSearchInput.js?
TimelineSearchInput.js is imported by 1 file(s): Timeline.js.
Where is TimelineSearchInput.js in the architecture?
TimelineSearchInput.js is located at packages/react-devtools-timeline/src/TimelineSearchInput.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-timeline/src).

Analyze Your Own Codebase

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

Try Supermodel Free