Fix when search sends queries
This commit is contained in:
parent
41f8753169
commit
91d8dc7ae4
1 changed files with 5 additions and 3 deletions
|
|
@ -43,15 +43,17 @@ const SearchModal = (props: Props) => {
|
|||
searchInput.current.focus()
|
||||
}, [searchInput])
|
||||
|
||||
useEffect(() => {
|
||||
if (query.length > 2)
|
||||
fetchResults()
|
||||
}, [query])
|
||||
|
||||
function inputChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
||||
const text = event.target.value
|
||||
if (text.length) {
|
||||
setQuery(text)
|
||||
setLoading(true)
|
||||
setMessage('')
|
||||
|
||||
if (text.length > 2)
|
||||
fetchResults()
|
||||
} else {
|
||||
setQuery('')
|
||||
setResults({})
|
||||
|
|
|
|||
Loading…
Reference in a new issue