File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export type Definition = {
3030 }
3131 searchEnd : {
3232 id : number
33+ inputValue : string
3334 }
3435 }
3536 child2parent : {
Original file line number Diff line number Diff line change 11import type { SgSearch } from '../postMessage'
22import { childPort } from '../postMessage'
3- import { useCallback , useMemo , useSyncExternalStore } from 'react'
3+ import {
4+ useCallback ,
5+ useDeferredValue ,
6+ useMemo ,
7+ useSyncExternalStore
8+ } from 'react'
49import { useDebounce } from 'react-use'
510
611// id should not overflow, the MOD is large enough
@@ -36,6 +41,7 @@ childPort.onMessage('searchEnd', event => {
3641 return
3742 }
3843 searching = false
44+ queryInFlight = event . inputValue
3945 notify ( )
4046} )
4147
@@ -75,9 +81,11 @@ export const useSearchResult = (inputValue: string) => {
7581 postSearch ( inputValue )
7682 } , [ inputValue ] )
7783
78- const groupedByFileSearchResult = useMemo ( ( ) => {
84+ const grouped = useMemo ( ( ) => {
7985 return [ ...groupBy ( searchResult ) . entries ( ) ]
8086 } , [ searchResult ] )
87+ // rendering tree is too expensive, useDeferredValue
88+ const groupedByFileSearchResult = useDeferredValue ( grouped )
8189
8290 useDebounce ( refreshSearchResult , 100 , [ inputValue ] )
8391
You can’t perform that action at this time.
0 commit comments