From ab6238a534d6b551c5e15337ebf4ce53919c133f Mon Sep 17 00:00:00 2001 From: neko Date: Tue, 8 Nov 2022 16:38:46 +0300 Subject: [PATCH] add loading --- src/s2-homeworks/hw14/HW14.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/s2-homeworks/hw14/HW14.tsx b/src/s2-homeworks/hw14/HW14.tsx index 9387a19..5f2634b 100644 --- a/src/s2-homeworks/hw14/HW14.tsx +++ b/src/s2-homeworks/hw14/HW14.tsx @@ -26,15 +26,20 @@ const getTechs = (find: string) => { const HW14 = () => { const [find, setFind] = useState('') + const [isLoading, setLoading] = useState(false) const [searchParams, setSearchParams] = useSearchParams() const [techs, setTechs] = useState([]) const sendQuery = (value: string) => { + setLoading(true) getTechs(value) .then((res) => { // делает студент - if (res) setTechs(res.data.techs) + if (res) { + setTechs(res.data.techs) + } + setLoading(false) // }) @@ -75,6 +80,9 @@ const HW14 = () => { onChangeText={onChangeText} onDebouncedChange={sendQuery} /> + + {isLoading && '...ищем'} + {mappedTechs}