Added more options to the User List

This commit is contained in:
Tiago Ribeiro
2023-09-26 13:23:53 +01:00
parent b0a11a5f8d
commit 733138f2be
6 changed files with 122 additions and 18 deletions

View File

@@ -7,13 +7,15 @@ export default function useUsers() {
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(false);
useEffect(() => {
const getData = () => {
setIsLoading(true);
axios
.get<User[]>("/api/users/list")
.then((response) => setUsers(response.data))
.finally(() => setIsLoading(false));
}, []);
};
return {users, isLoading, isError};
useEffect(getData, []);
return {users, isLoading, isError, reload: getData};
}