I’m trying to create a COVID Dashboard using disease.sh API (I’m learning Web dev and React atm).
I’m storing the global data in globalData
and trying to get the countries list in countries
. After that, my plan is to display it in a dropdown menu (Dropdown component).
My question : when getting datas, if I console.log, there is always an empty array (initial state I presume). Just wanted to know, as I’m learning all of this, if it was the correct approach :
- having my fetching and states in App
- passing them as props to my components to display data
And, is it possible to prevent that empty array phase ? Am I architecturing it the wrong way ?
Here is my App component :
const App = () => {
const [globalData, setGlobalData] = useState([]);
//const [countryData, setCountryData] = useState({});
const [countries, setCountries] = useState([]);
useEffect(() => {
getCountriesData();
getGlobalData();
}, []);
const getGlobalData = async () => {
const response = await diseaseAPI.get("/v3/covid-19/all");
setGlobalData(response.data);
};
const getCountriesData = async () => {
const response = await diseaseAPI.get("/v3/covid-19/countries");
const countries = response.data.map((country) => ({
countryName: country.country,
countryCode: country.countryInfo.iso2,
countryFlag: country.countryInfo.flag,
}));
setCountries(countries);
};
return (
<div>
<ThemeProvider theme={darkTheme}>
<CssBaseline />
<AppBar position="static">
<Toolbar>
<Typography variant="h6">COVID-19 Tracker</Typography>
</Toolbar>
</AppBar>
<Container maxWidth={false}>
<h1>Worldwide data</h1>
<Dropdown countries={countries} />
<Grid
container
direction="row"
justify="center"
alignItems="center"
spacing={3}
>
<Grid item xs>
<InfoBox
label="Total cases"
total={numeral(globalData.cases).format()}
cases={numeral(globalData.todayCases).format("+0,0")}
/>
</Grid>
<Grid item xs>
<InfoBox
label="Total deaths"
total={numeral(globalData.deaths).format()}
cases={numeral(globalData.todayDeaths).format("+0,0")}
/>
</Grid>
<Grid item xs>
<InfoBox
label="Recovered"
cases={numeral(globalData.todayRecovered).format("+0,0")}
total={numeral(globalData.recovered).format()}
/>
</Grid>
</Grid>
<small>Last update: {convertUnixTime(globalData.updated)}</small>
</Container>
</ThemeProvider>
</div>
);
};
export default App;
My InfoBox component :
const InfoBox = ({ label, cases, total }) => {
return (
<>
<Card>
<CardContent>
<Typography variant="h4" color="textSecondary" gutterBottom>
{label}
</Typography>
<Typography variant="h5" color="textPrimary" gutterBottom>
{total !== "0" ? total : "Loading..."}
</Typography>
<Typography variant="body2" color="textPrimary" gutterBottom>
{cases !== "+0" ? `${cases} today` : "Loading..."}
</Typography>
</CardContent>
</Card>
</>
);
};
export default InfoBox;
My Dropdown component :
const Dropdown = ({ countries }) => {
//console.log(countries);
//if (!countries) return <div>Loading...</div>;
const renderedCountries = countries.map((country) => {
return <li key={country.countryName}>{country.countryName}</li>;
});
return (
<div>
<ul>{renderedCountries}</ul>
</div>
);
};
Here is also the github repo. Thank you all, and sorry if it’s not clear enough, feel free to ask me to be more explicite !
http://cialisbob.com/ cialis without a doctor’s prescription india
http://levitraoffer.com levitra versus viagra
https://wardenafil.com how to make levitra work better
http://stromectolhumans.com ivermectin
http://gabenhim.com medications without doctor’s prescription
https://prescriptionhim.com/ viagra without a prescription
https://stromectolhumans.com/ ivermectin for humans for sale
http://iwermectin.com/ do i need a prescription for ivermectin
http://viagraxyu.com brand viagra 100mg
http://ivermectineffects.com/ ivermectin tablets
http://ivermectinovercounter.com/ ivermectin for humans dosage
https://ivermectineffects.com ivermectin for humans
buy stromectol europe – stromectol cream stromectol liquid
online casino slots no download – casino games win real money slots online
iasis healthcare employees how to help with toe arthritis
ivermectin https://ivermectinhome.com
erectile dysfunction treatments – erectile dysfunction pills the blue pill ed
prednisone best prices – 5mg prednisone daily prednisone 5 mg
how much is real viagra – buy viagra online fast delivery compare viagra prices uk
ivermectin tablets https://stromectolus.com stromectol
brazilian pharmacy online – Viagra or cialis cheap cialis 20mg online
stromectol tablets for sale – ivermectin over the counter uk stromectol 3mg online
missouri department of health and senior services jefferson city how celery lowers blood pressure
ivermectin tablets https://ivermectinhome.com
ivermectin https://stromectolus.com ivermectin human dosage
ed pills gnc – male ed pills erectile dysfunction natural treatment
ivermectin dosage for humans in pounds https://ivermcov.com/# ivermectin over the counter
can std be cured pineville mo health department
stromectol https://ivermectinhome.com
javascript-help.li and list of otc products http://pharmvolk.com meds without a doctor prescription
diocese of pittsburgh health insurance how do you get an std
ivermectin for humans https://ivermectinhome.com
how to get cytotec in canada – cytotec 200 mcg order online cytotec pills buy
javascript-help.li and ivermectin https://ivermectini.com stromectol over the counter walgreens pharmacy
cost of doxycycline australia – purchase doxycycline buy doxycycline online usa
neurontin prescription medication – neurontin coupon levothyroxine 25 mg price
countries with highest heart disease https://dapoxetineus.com/ dapoxetine order
javascript-help.li reviewed stromectol over the counter http://ivermectiny.com ivermectin tablets dosage
purchase accutane – accutane 30mg roche accutane
viagra without prescription http://viagrob.com where can i buy viagra
javascript-help.li reviewed ivermectin for humans over the counter http://ivermectinhum.com ivermectin
liquide stromectol generic stromectol http://stromectl.com ivermectin
prednisone 30 mg coupon – prednisone steroids prednisone 21 pack
ventolin price – ventoingo.com ventolin price australia
javascript-help.li and ivermectin https://ivermectiny.com ivermectin tablets for sale walmart
cytotec uk pharmacy – how to buy cytotec cytotec 200mg
ivermectin for human – ivermectina buy ivermectin 6mg
stromectol iso -britannia https://ivermectin1.com/ where to buy ivermectin
http://stromectolus.com – ivermectin
https://stromectolo.com – buy ivermectin 6mg
dosing for zithromax for patients on warfarin http://azithrozpack.com metronidazole buy
http://himshairloss.com – finasteride prostate
levitra online pharmacy – canada drugs online reviews causes of ed
https://stromectolforte.com/# stromectol 3mg scabies
cost of stromectol medication http://stromectolforte.com/# ivermectin ivermectin tablets
cialis brand for sale – cialis buy cialis buy tadalafil from canada
ivermectin 9 mg http://stromectoloff.com/ buy stromectol ivermectine
what is a aircraft health managemebt system http://zithrozpack.com – z pack medical name
stromectol online pharmacy https://stromectolforte.com/# where to buy stromectol ivermectin cream walmart
stromectol ivermectin http://stromectoloff.com/ ivermectin warnings
Aiprnfi http://www.ivermectinplls.com/ buy ivermectin online for dogs
viagra 150mg pill – cheap tadalafil 5mg cheap tadalafil tablets
viagra sans ordonnance en pharmacie – acheter 20mg tadalafil cialis generique
buy ivermectin 3mg online – stromectol 12mg pill ivermectin 12 mg tablets for humans
prednisone 5mg us – buying ed pills online prednisone ca
pregabalin 150mg pills – clomid 100mg us zithromax for sale online
doxycycline 100mg oral – cheap prednisolone pill synthroid 150mcg canada
tetracycline buy online – tetracycline 250mg over the counter cost celexa 20mg
cialis buy online – ivermectin 12 mg tablets ivermectin virus
buy augmentin 1000mg generic – ciprofloxacin online buy sulfamethoxazole pill
generic bimatoprost – bimatoprost for sale online oral trazodone 50mg
tadalafil 20mg tablet – cost tadalafil ivermectin 12 mg pills for humans
buy amoxicillin 1000mg online – amoxicillin 250mg ca viagra 50mg pill
ivermectin gel – buy ivermectin 3mg for humans azithromycin pills
cost cytotec – order prednisolone 20mg synthroid 75mcg oral
order sildenafil 100mg for sale – buy gabapentin 800mg for sale order neurontin pills
oral cialis 20mg – buy cialis 5mg online cheap cenforce 100mg oral
order diltiazem 180mg without prescription – order diltiazem pill acyclovir price
buy atarax 25mg for sale – order rosuvastatin 10mg online cheap generic rosuvastatin
buy zetia 10mg for sale – domperidone 10mg ca celexa 40mg brand
sildenafil 200 mg – cyclobenzaprine brand cyclobenzaprine ca
sildenafil 100mg pill – buy cialis 20mg without prescription cialis 20mg without prescription
viagra in usa – viagra pills 100mg plavix 150mg drug
free shipping viagra – buy viagra sale sildenafil 25mg
buy esomeprazole 20mg online cheap – promethazine pill promethazine ca
cialis sales – Buy cialis in us price of cialis
oral modafinil – ed pills online cheap ed drugs
isotretinoin 40mg usa – amoxicillin 1000mg pills order zithromax 500mg generic
order lasix 40mg – order sildenafil 100mg without prescription viagra in usa
tadalafil 5mg pill – order cialis 20mg online cheapest viagra
buy tadalafil sale – tadalafil 40mg for sale coumadin 2mg drug
ed pills that work quickly – male ed pills order prednisone 40mg sale
buy generic accutane – purchase amoxil cheap amoxicillin generic
lasix 40mg brand – order azithromycin 500mg zithromax generic
buy prednisone for sale – order generic orlistat cost amoxicillin 1000mg
order cenforce pill – zetia 10mg usa order motilium online
order accutane 20mg generic – buy isotretinoin 20mg generic purchase tetracycline pill
cyclobenzaprine oral – inderal price order generic inderal 20mg
cozaar for sale online – order topiramate 100mg without prescription purchase phenergan
purchase levofloxacin generic – order generic avodart cialis otc
ondansetron for sale online – spironolactone brand purchase valacyclovir without prescription
fildena 100mg sale – viagra 150mg brand sildenafil over the counter
blue pill for ed – sildenafil 200mg bestellen viagra 100mg generika rezeptfrei kaufen
prednisone 40mg pill – accutane generic order generic prednisolone
cyclobenzaprine cheap cost toradol generic plavix 75mg
buy methotrexate generic cheap warfarin purchase metoclopramide without prescription
order viagra 150mg pills order cialis 20mg generic prednisone 20mg generic
generic accutane 10mg order isotretinoin pills order aurogra 100mg pill
sildenafil 25mg order lamictal for sale losartan 50mg price
order nexium 40mg generic buy generic phenergan cialis tablet
buy cialis sale order imitrex for sale dutasteride pills
zantac canada buy generic meloxicam 15mg buy flomax 0.4mg pills
ondansetron 8mg over the counter buy ondansetron 4mg generic finasteride 5mg oral
cialis 5mg for sale order cialis 5mg sildenafil 50mg tablet
buy azithromycin 250mg pill buy stromectol for sale glucophage price
order cleocin 300mg generic budesonide oral rhinocort ca
order ceftin cialis 5mg cheap cialis 5mg generic