-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (36 loc) · 1.22 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
export default function Table() {
const [posts, setPosts] = useState([]);
const [loading, setLoading] = useState(false);
const [currentPage, setCurrentPage] = useState(1);
const [postsPerPage, setPostsPerPage] = useState(10);
useEffect(() => {
const fetchUsers = async () => {
const res = await axios.get("https://jsonplaceholder.typicode.com/posts");
setUsers(res.data);
setLoading(false);
};
fetchUsers();
}, []);
return (
<div>
<table className="table">
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
<tbody>
<Users />
</tbody>
</table>
<section className="pagination">
<button className="first-page-btn">first</button>
<button className="previous-page-btn">previous</button>
<button className="next-page-btn">next</button>
<button className="last-page-btn">last</button>
</section>
</div>
);
};