userroom.jsx
753 Bytes
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
import axios from "axios";
import { useState, useEffect } from "react";
// components
import Bottombar from "../components/Bottombar";
import Topbar from "../components/Topbar";
import UserBox from "../components/UserBox";
const Userroom = () => {
const [users, setUsers] = useState(null);
useEffect(() => {
axios.get("/api/users/all/").then((response) => {
setUsers(response.data);
});
}, []);
if (!users) return null;
return (
<div>
<Topbar />
<h1>User Room</h1>
<div>
{Array.isArray(users)
? users.map((user, i) => {
return <UserBox key={i} user={user} />;
})
: ""}
</div>
<Bottombar />
</div>
);
};
export default Userroom;