()
| 20 | // while this will not happen when using `React.useState`, |
| 21 | // so we should create an intermediate `keyword` state to fix this. |
| 22 | function 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 | |
| 37 | export const SearchView: React.FC<PaneViewProps> = (props) => { |
| 38 | const [action] = useAction() |
no test coverage detected