From 3fbc0580f53c526a8e2c1ab726efd17ad32597b4 Mon Sep 17 00:00:00 2001 From: Firesieht Date: Sat, 22 Oct 2022 23:41:15 +0300 Subject: [PATCH] add spinner --- сomponents/search/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/сomponents/search/index.tsx b/сomponents/search/index.tsx index 76cd9ed..635f284 100644 --- a/сomponents/search/index.tsx +++ b/сomponents/search/index.tsx @@ -10,8 +10,10 @@ import styles from "./search.module.css" export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ const [data, setData] = useState("") const [tags, setTags] = useState(new Array()) + const [loading, setLoading] = useState(false) const dispatch = useAppDispatch(); const getNodes = useAppSelector(nodes); + const getProducts = useAppSelector(products); const getHints = useAppSelector(hints); const [autoCompleteValue, setAutoCompleteValue] = useState("") const onChange = (text:string) =>{ @@ -67,6 +69,7 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ } const onEnter = (value:any) => { + setLoading(true) console.log(getNodes); dispatch( search( @@ -127,6 +130,7 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ onSearch={(e) => onEnter(e)} size="large" placeholder="Поиск товара" + loading={loading && getProducts.length == 0} enterButton />