mirror of
https://github.com/ivabus/www
synced 2024-11-10 12:15:15 +03:00
Preloader added to bottles.jsx
This commit is contained in:
parent
f737eeff10
commit
ef74d4fc00
|
@ -1,12 +1,17 @@
|
|||
function Bottles() {
|
||||
const [bottles, setBottles] = React.useState();
|
||||
const [isLoading, setLoading] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
fetch("https://app.tea.xyz/api/bottles")
|
||||
.then((res) => res.json())
|
||||
.then((res) => setBottles(res));
|
||||
.then((res) => {
|
||||
setBottles(res);
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (isLoading) return <p>Loading...</p>;
|
||||
if (!bottles) return null;
|
||||
|
||||
const names = [...new Set(bottles.map((b) => b.name))];
|
||||
|
|
Loading…
Reference in a new issue