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.current.focus()
|
||||||
}, [searchInput])
|
}, [searchInput])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (query.length > 2)
|
||||||
|
fetchResults()
|
||||||
|
}, [query])
|
||||||
|
|
||||||
function inputChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
function inputChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
||||||
const text = event.target.value
|
const text = event.target.value
|
||||||
if (text.length) {
|
if (text.length) {
|
||||||
setQuery(text)
|
setQuery(text)
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
setMessage('')
|
setMessage('')
|
||||||
|
|
||||||
if (text.length > 2)
|
|
||||||
fetchResults()
|
|
||||||
} else {
|
} else {
|
||||||
setQuery('')
|
setQuery('')
|
||||||
setResults({})
|
setResults({})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue