From f6c75d0f743475d315708b025c456496ca18ee56 Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Mon, 2 May 2022 19:15:38 -0700 Subject: [PATCH] doc: create getCountriesData with app__header class --- src/App.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 581f24b..1bbac74 100644 --- a/src/App.js +++ b/src/App.js @@ -1,9 +1,44 @@ -import React from 'react'; -import './App.css'; +import React, { useEffect, useState } from "react"; +import { FormControl, Select, MenuItem } from "@material-ui/core"; +import "./App.css"; function App() { + const [countries, setCountries] = useState([]); + const [country, setCountry] = useState("worldwide"); + + useEffect(() => { + const getCountriesData = async () => { + await fetch("https://disease.sh/v3/covid-19/countries") + .then((response) => response.json()) + .then((data) => { + const countries = data.map((country) => ({ + name: country.country, + value: country.countryInfo.iso2, + })); + setCountries(countries); + }); + }; + getCountriesData(); + }, [countries]); + + const countryChange = (e) => { + const countryCode = e.target.value; + setCountry(countryCode); + }; return ( -
+
+
+

COVID-19 Tracker

+ + + +
+
); }