mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 04:39:45 +00:00
Все и сразу, давно делал, лень разбираться
This commit is contained in:
1 parent
4978c36070
commit
ab9438b5b9
32 files changed
+389
-120
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { useState } from "react";
|
||||
|
||||
function LoadMore({list, setter, loader, count, setFull}) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const handleLoadMore = async () => {
|
||||
setIsLoading(true);
|
||||
const newPart = await loader(count, list.length);
|
||||
const newList = [...list, ...newPart];
|
||||
setter(newList);
|
||||
setIsLoading(false);
|
||||
|
||||
if (newPart.length < count) {
|
||||
setFull(true);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button className="btn" onClick={handleLoadMore} disabled={isLoading} >
|
||||
Показать еще
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoadMore;
|
||||
Reference in new issue
Block a user