LocChat/client/components/admin/_admin.jsx

22 lines
495 B
React
Raw Normal View History

2021-12-01 22:18:26 -05:00
import { useState, useContext, useEffect } from 'react';
import { ApiContext } from '../../utils/api_context';
export const Admin = () => {
const [users, setUsers] = useState([]);
const api = useContext(ApiContext);
useEffect(async () => {
const { users } = await api.get('/users');
setUsers(users);
}, []);
return (
<div className="p-4">
<h2 className="text-3xl">Users</h2>
{users.map((user) => (
<div>{user.name}</div>
))}
</div>
);
};