MCPcopy Create free account
hub / github.com/pacexy/flow / useIntermediateKeyword

Function useIntermediateKeyword

apps/reader/src/components/viewlets/SearchView.tsx:22–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20// while this will not happen when using `React.useState`,
21// so we should create an intermediate `keyword` state to fix this.
22function useIntermediateKeyword() {
23 const [keyword, setKeyword] = useState('')
24 const { focusedBookTab } = useReaderSnapshot()
25
26 useEffect(() => {
27 setKeyword(focusedBookTab?.keyword ?? '')
28 }, [focusedBookTab?.keyword])
29
30 useEffect(() => {
31 reader.focusedBookTab?.setKeyword(keyword)
32 }, [keyword])
33
34 return [keyword, setKeyword] as const
35}
36
37export const SearchView: React.FC<PaneViewProps> = (props) => {
38 const [action] = useAction()

Callers 1

SearchViewFunction · 0.85

Calls 2

useReaderSnapshotFunction · 0.90
setKeywordMethod · 0.80

Tested by

no test coverage detected