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