2. 로그인, 사용자 목록
사용자 목록
export default function UserListPage() {
const { users, loading, error } = useFetchUsers();
if (loading) {
return <p>Loading...</p>;
}
if (error) {
return <p>Error!</p>;
}
return (
<Container>
<h2>Users</h2>
<table>
<thead>
<tr>
<th>이름</th>
<th>이메일</th>
<th>역할</th>
</tr>
</thead>
<tbody>
{users.map((user) => (
<tr key={user.id}>
<td>{user.name}</td>
<td>{user.email}</td>
<td>{user.role}</td>
</tr>
))}
</tbody>
</table>
</Container>
);
}useFetchUsers hook
useFetch
ApiService
Last updated