-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
72 lines (54 loc) · 1.84 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { useEffect, useState } from 'react'
function App() {
// const [active,setActive]=useState('');
// const [recovered,setRecoevered]=useState('');
// const [total,setTotal]=useState('');
// const [death,setDeath]=useState('');
const [country,setCountry]=useState('');
const [datas,setDatas]=useState('')
// useEffect(() => {
// Covid();
// }, []);
const Covid=()=>{
const url=`https://corona.lmao.ninja/v2/countries/${country}`;
fetch(url)
.then(response=>response.json())
.then(data=>{
console.log(data);
setDatas(data);
// setActive(data.active);
// setRecoevered(data.recovered);
// setTotal(data.cases);
// setDeath(data.deaths);
})
}
// const newCovid=()=>{
// Covid();
// }
return (
<>
<div className="container">
<h1>Covid Tracker</h1>
<input type="text" placeholder='Country' value={country} onChange={(e)=>setCountry(e.target.value)} />
<button onClick={Covid}>Check</button>
<div className="boxes"> <div className="box" id="box-1">
<h3>Active Cases</h3>
<p>{datas.active}</p>
</div>
<div className="box" id="box-2">
<h3>Recovered Cases</h3>
<p>{datas.recovered}</p>
</div>
<div className="box" id="box-3">
<h3>Total Cases</h3>
<p>{datas.cases}</p>
</div>
<div className="box" id="box-4">
<h3>Total Deaths</h3>
<p>{datas.deaths}</p>
</div></div>
</div>
</>
)
}
export default App