diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2022-05-05 07:01:55 +0000 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2022-05-05 07:27:44 +0000 |
commit | 0d17912972de6b9e8b08aedf141260413c60d7fd (patch) | |
tree | f0a56bfea9204dd3067c43e2667e3d70e581d183 /src/console/components/CommandPrompt.tsx | |
parent | bc890c55bfbd6d1aa4ece5b0ef96a9ab6d358ad7 (diff) |
Use useDebounce
Diffstat (limited to 'src/console/components/CommandPrompt.tsx')
-rw-r--r-- | src/console/components/CommandPrompt.tsx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/console/components/CommandPrompt.tsx b/src/console/components/CommandPrompt.tsx index 0e2506c..0312fe4 100644 --- a/src/console/components/CommandPrompt.tsx +++ b/src/console/components/CommandPrompt.tsx @@ -3,6 +3,7 @@ import Completion from "./console/Completion"; import Input from "./console//Input"; import styled from "styled-components"; import { useCompletions, useSelectCompletion } from "../completion/hooks"; +import useDebounce from "../hooks/useDebounce"; import useAutoResize from "../hooks/useAutoResize"; import { CompletionProvider } from "../completion/provider"; import { useExecCommand, useHide } from "../app/hooks"; @@ -20,6 +21,7 @@ interface Props { const CommandPromptInner: React.FC<Props> = ({ initialInputValue }) => { const hide = useHide(); const [inputValue, setInputValue] = React.useState(initialInputValue); + const debouncedValue = useDebounce(inputValue, 100); const { completions, updateCompletions } = useCompletions(); const { select, currentValue, selectNext, selectPrev } = useSelectCompletion(); @@ -82,8 +84,8 @@ const CommandPromptInner: React.FC<Props> = ({ initialInputValue }) => { }; React.useEffect(() => { - updateCompletions(inputValue); - }, [inputValue]); + updateCompletions(debouncedValue); + }, [debouncedValue]); return ( <ConsoleWrapper> |