diff --git a/src/assets/scripts/package-bottles.jsx b/src/assets/scripts/package-bottles.jsx index 8e10065..79b1061 100644 --- a/src/assets/scripts/package-bottles.jsx +++ b/src/assets/scripts/package-bottles.jsx @@ -1,13 +1,19 @@ function PackageBottles() { const [bottles, setBottles] = React.useState(); + const [isLoading, setIsLoading] = React.useState(true); React.useEffect(() => { const url = window.location.pathname.replace('/+', 'https://app.tea.xyz/api/bottles/'); fetch(url) .then((res) => res.json()) - .then((res) => setBottles(res)); + .then((res) => { + setBottles(res); + setIsLoading(false); + }); }, []); + if (isLoading) return
Loading...
; + if (!bottles) return null; const names = [...new Set(bottles.map((b) => b.name))];