-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
46 lines (46 loc) · 1.36 KB
/
App.js
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
import './App.css';
import React,{useEffect,useState} from 'react'
function App() {
const [users, setUsers] = useState([]);
const [isDataTaken, setisDataTaken] = useState(false);
const [myBtnClick, setisBtnClick] = useState(false);
const fetchdata = async () => {
setisBtnClick(true);
const response = await fetch("https://reqres.in/api/users?page=1");
const jsonresponse = await response.json();
setUsers(jsonresponse.data);
setInterval(() => {
setisDataTaken(true);
}, 1550);
};
return (
<div className='bigcontainer'>
<div>
<button type="button" onClick={fetchdata} className="btns">Get Users</button>
</div>
{myBtnClick ? (
isDataTaken ? (
<div className='us'>
{users.map(({ id, first_name, last_name, avatar, email }) => {
return (
<div className="container">
<div className='fordis'>
<img height={250} src={avatar} className='ig'></img>
<h3 className='fn'>
{first_name} {last_name}
</h3>
</div>
</div>
)
})}
</div>
) : (
<div className='dull'> <h3>Loading Users...</h3></div>
)
) : (
<> </>
)}
</div>
);
}
export default App;