mirror of
https://github.com/ivabus/www
synced 2024-11-26 06:25:06 +03:00
package-bottle.jsx edit to inlude loading
This commit is contained in:
parent
2be6f65817
commit
5de6a86c16
1 changed files with 7 additions and 1 deletions
|
@ -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 <div>Loading...</div>;
|
||||
|
||||
if (!bottles) return null;
|
||||
|
||||
const names = [...new Set(bottles.map((b) => b.name))];
|
||||
|
|
Loading…
Reference in a new issue