Filtered menu items page
Purpose of the project is to train myself on:
- using useState,
- Iterating through the items data and filtering the rendered data based on item category
- React.Js
- Filtering and rendering items based on their categories:
const filterItems = (category) => {
if (category === 'all') {
setMenuItems(items);
return;
}
const newItems = items.filter((item) => item.category === category);
setMenuItems(newItems);
};
After you clone this repo to your desktop, go to its root directory and run npm install
to install its dependencies.
Once the dependencies are installed, you can run npm start
to start the application. You will then be able to access it at localhost:3000
Credits to an awesome instructor John Smilga!