This project was based on the YouTube video Intermediate React.js Coding Interview (ft. Clément Mihailescu) by Ben Awad and Clément Mihailescu
The Challenge:
- Fetch the data from
https://randomuser.me/api/
- Generate a table based on the users' address details
- Enable sorting based on columns
- Add an field which will enable filtering based on values on rows
- Install the dependencies using
npm install
- Run the application using
npm run start
npm install
npm run start
- Use
fetch
to get data from the api reference; called once on mount of the page/application - Deconstruct the data and format it the way I wanted to show in my table
- Create a mapping of the key and name and save it as the
header
object array - Create a separate component for the table headers (column) and table data (rows)
- Add an input field for filtering text
- Create a pure function
tableFilterText
to filter all the users based onfilterText
which is updated on change of the input field - Add a
handleSort
onClick function to column headers - Create a pure function
tableSortByColumn
to sort based onsortObject
which is updated onhandleSort