mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2025-12-18 12:31:16 +00:00
add loading
This commit is contained in:
@@ -26,15 +26,20 @@ const getTechs = (find: string) => {
|
|||||||
|
|
||||||
const HW14 = () => {
|
const HW14 = () => {
|
||||||
const [find, setFind] = useState('')
|
const [find, setFind] = useState('')
|
||||||
|
const [isLoading, setLoading] = useState(false)
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const [techs, setTechs] = useState<string[]>([])
|
const [techs, setTechs] = useState<string[]>([])
|
||||||
|
|
||||||
const sendQuery = (value: string) => {
|
const sendQuery = (value: string) => {
|
||||||
|
setLoading(true)
|
||||||
getTechs(value)
|
getTechs(value)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// делает студент
|
// делает студент
|
||||||
|
|
||||||
if (res) setTechs(res.data.techs)
|
if (res) {
|
||||||
|
setTechs(res.data.techs)
|
||||||
|
}
|
||||||
|
setLoading(false)
|
||||||
|
|
||||||
//
|
//
|
||||||
})
|
})
|
||||||
@@ -75,6 +80,9 @@ const HW14 = () => {
|
|||||||
onChangeText={onChangeText}
|
onChangeText={onChangeText}
|
||||||
onDebouncedChange={sendQuery}
|
onDebouncedChange={sendQuery}
|
||||||
/>
|
/>
|
||||||
|
<span id={'hw14-loading'}>
|
||||||
|
{isLoading && '...ищем'}
|
||||||
|
</span>
|
||||||
{mappedTechs}
|
{mappedTechs}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user