Skip to content

Latest commit

 

History

History
111 lines (72 loc) · 2.46 KB

File metadata and controls

111 lines (72 loc) · 2.46 KB

React Patterns

This repository demonstrates advanced React design patterns including Compound Components, Render Props, and Debouncing, implemented in a simple Vite + React setup.

It’s meant as a learning resource and a reference project for developers who want to understand and apply these patterns in real-world applications.


🚀 Features

  • Compound Components – Build flexible APIs where the parent manages state and child components consume it.
  • Render Props – Share reusable stateful logic while leaving rendering control to the user.
  • Debouncing – Optimize performance by reducing unnecessary re-renders or API calls while typing.

📸 Demo / Screenshots

Compound Components (Toggle Example)

Compound Components


Render Props (DataFetcher Example)

Render Props


Debouncing (Search Input Example)

Debouncing


📂 Project Structure


react-patterns/
├── src/
│   ├── components/
│   │   ├── Compound/        # Compound Components pattern
│   │   ├── RenderProps/     # Render Props pattern
│   │   └── Debounce/        # Debouncing pattern
│   ├── hooks/               # Custom hooks like useDebounce
│   ├── App.jsx              # Main entry component
│   └── main.jsx             # ReactDOM entry
├── public/
├── docs/                    # Screenshots and GIFs for README
├── package.json
├── vite.config.js
└── README.md


⚡ Getting Started

Prerequisites

  • Node.js (>= 20)
  • npm or yarn

Installation

git clone https://github.com/AqibNiazi/react-patterns.git
cd react-patterns
npm install

Run Development Server

npm run dev

Build for Production

npm run build

🤝 Contributing

Contributions are welcome! You can add new patterns (like Higher-Order Components, State Reducers, Portals, etc.), improve documentation, or suggest better examples.

Steps:

  1. Fork the repo
  2. Create a branch: git checkout -b feature/my-pattern
  3. Commit your changes
  4. Push to the branch: git push origin feature/my-pattern
  5. Open a pull request

📜 License

MIT License © 2025 Aqib Niazi


⭐ Support

If you found this helpful, consider giving the repository a ⭐ on GitHub!