-
Notifications
You must be signed in to change notification settings - Fork 47.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor SearchInput component (used in Components tree) to be generic DevTools component with two uses: ComponentSearchInput and TimelineSearchInput. Refactored Timeline Suspense to more closely match other, newer Suspense patterns (e.g. inspect component, named hooks) and colocated Susepnse code in timelineCache file. Add search by component name functionality to the Timeline. For now, searching zooms in to the component measure and you can step through each time it rendered using the next/previous arrows.
- Loading branch information
Brian Vaughn
committed
Nov 21, 2021
1 parent
149b420
commit 68f39c6
Showing
15 changed files
with
481 additions
and
85 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/react-devtools-shared/src/devtools/views/Components/ComponentSearchInput.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 {TreeDispatcherContext, TreeStateContext} from './TreeContext'; | ||
|
||
import SearchInput from '../SearchInput'; | ||
|
||
type Props = {||}; | ||
|
||
export default function ComponentSearchInput(props: Props) { | ||
const {searchIndex, searchResults, searchText} = useContext(TreeStateContext); | ||
const dispatch = useContext(TreeDispatcherContext); | ||
|
||
const search = text => 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 ( | ||
<SearchInput | ||
goToNextResult={goToNextResult} | ||
goToPreviousResult={goToPreviousResult} | ||
placeholder="Search (text or /regex/)" | ||
search={search} | ||
searchIndex={searchIndex} | ||
searchResultsCount={searchResults.length} | ||
searchText={searchText} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.