Project: Components, Props, State, and useEffect
Build a small product catalog app that fetches a list of products and displays them with custom styling. This project will practice the following concepts:
useStateto store fetched product datauseEffectto load product data when the component first renders- component composition and props to render product details in child components
- rendering a list with
mapandkey - writing custom CSS to make the UI look polished
Project requirements
- Create a parent component that fetches product data from an open API when it first renders.
- Store the fetched product list in state using
useState. - Render a child component for each product, passing data through props.
- Show a loading indicator while the product data is being fetched.
- Add custom CSS so the product cards look visually appealing.
Data source
Use this public product API endpoint:
https://dummyjson.com/products
This endpoint returns a JSON object with a products array.
What to show for each product card
Each product card should include:
- id
- title
- price
- description
- category
- thumbnail
Bonus idea
If you want to make the project feel more like a real store, add a simple cart button and a cart count. If you want to try a POST request, you can also explore https://dummyjson.com/products/add for creating a new product.