This project is a demonstration of the Single Responsibility Principle (SRP) applied to a React application. It showcases a simple product listing application with filtering functionality based on product ratings.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before you begin, ensure you have met the following requirements:
- You have installed Node.js and npm.
- You have a basic understanding of React and TypeScript.
- Clone the repo
git clone https://github.com/adeeshsharma/SRP-REACT-DEMO.git
- Navigate into the project directory
cd SRP-REACT-DEMO
- Install the dependencies
yarn
Start the development server with:
yarn dev
The main files in the project are located in the src directory:
- components/product.tsx: Displays individual product details.
- components/filter.tsx: Provides a filter by rating functionality.
- hooks/useProducts.tsx: Custom hook for fetching and managing product data.
- hooks/useRateFilter.tsx: Custom hook for managing the state of the rating filter.
- pages/good-approach.tsx: The main page that integrates all the components and hooks to showcase the SRP approach.
This project uses the Fake Store API for product data.