Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import logo from "./logo.svg";
import "./App.css";
import { UsersList } from "./components/UsersList";

function App() {
return (
Expand All @@ -19,6 +20,7 @@ function App() {
Learn React
</a>
</header>
<UsersList />
</div>
);
}
Expand Down
34 changes: 34 additions & 0 deletions src/components/UsersList/UsersList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useEffect, useState } from "react";

type User = {
id: string;
fullName: string;
email: string;
username: string;
};

const UsersList = () => {
const [loading, setLoading] = useState(false);
const [users, setUsers] = useState<User[]>([]);
useEffect(() => {
const loadUsers = async () => {
setLoading(true);
const data = await fetch("http://127.0.0.1:3001/users");
setUsers(data);
};

loadUsers();
});

if (loading) return <h1>Loading</h1>;

return (
<ul>
{users.map(user => (
<li>{user.fullName}</li>
))}
</ul>
);
};

export { UsersList };
1 change: 1 addition & 0 deletions src/components/UsersList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./UsersList";