Junior — Senior
User table with city filter
livecode
Task condition
It is necessary to implement a React component UserTable2 that displays a list of users in a table.
Requirements:
- Fetch an array of users from the API
https://jsonplaceholder.typicode.com/users. - The table should contain columns: ID, Name, Email, City.
- Place the header User List above the table.
- Add a dropdown list labeled "Filter by city". When a specific city is selected, only users from that city are displayed in the table, and when All is selected, the entire list is shown.
const apiUrl = "https://jsonplaceholder.typicode.com/users";
const UserTable2 = () => {
return <div></div>;
};
export default UserTable2;
Example of the expected view:
User List
[ Filter by city: All ▼ ]
| ID | Name | City | |
|---|---|---|---|
| 1 | Leanne Graham | Sincere@april.biz | Gwenborough |
| 2 | Ervin Howell | Shanna@melissa.tv | Wisokyburgh |
| 3 | Clementine Bauch | Nathan@yesenia.net | McKenziehaven |
| 4 | Patricia Lebsack | Julianne.OConner@kory.org | South Elvis |
| 5 | Chelsey Dietrich | Lucio_Hettinger@annie.ca | Roscoeview |
| 6 | Mrs. Dennis Schulist | Karley_Dach@jasper.info | South Christy |
| 7 | Kurtis Weissnat | Telly.Hoeger@billy.biz | Howemouth |
| 8 | Nicholas Runolfsdottir V | Sherwood@rosamond.me | Aliyaview |
| 9 | Glenna Reichert | Chaim_McDermott@dana.io | Bartholomebury |
| 10 | Clementina DuBuque | Rey.Padberg@karina.biz | Lebsackbury |