Skip to content

ayush-gupta07/react-hooks

Repository files navigation

🎯 React Hooks - Complete Learning Resource

A comprehensive learning resource for React Hooks with beautiful documentation, practical examples, and interactive demos. Perfect for developers preparing for interviews or mastering React fundamentals.


πŸ“– Project Overview

This repository is a dual-purpose learning platform that combines:

  1. πŸ“š Beautiful Documentation Site - Built with VitePress featuring comprehensive notes on all React Hooks
  2. βš›οΈ Interactive React Application - Built with Vite + React 19 + TypeScript for hands-on examples

🎯 Purpose & Goals

  • Educational Resource: Master all React Hooks from basic to advanced
  • Interview Preparation: Concise notes with common Q&A patterns
  • Practical Examples: Runnable code examples for each hook
  • Modern Setup: Latest React 19 features with TypeScript support
  • Beautiful UI: Custom-styled documentation with responsive design

πŸš€ Quick Start

Development

# Start React application (Interactive examples)
npm run dev
# β†’ http://localhost:5173

# Start documentation site
npm run docs:dev
# β†’ http://localhost:5174

# Run both simultaneously (recommended)
npm run dev & npm run docs:dev

πŸ“š Documentation Features

πŸ“– Content Structure

Each hook documentation includes:

  • πŸ“‹ Quick Summary: Concise overview with key points
  • 🧠 Mental Model: Conceptual understanding of how the hook works
  • πŸ”‘ Key Concepts: Essential patterns and use cases
  • πŸ’» Code Examples: Practical, runnable examples with explanations
  • ⚠️ Common Pitfalls: What to avoid and why
  • βœ… Best Practices: Professional patterns and recommendations
  • ❓ Interview Q&A: Common interview questions with detailed answers

πŸ”— Quick Navigation - Direct Links to Hook Documentation

🎯 Core Hooks

Hook Description Documentation Link
useState State management πŸ“„ useState.md
useEffect Side effects & lifecycle πŸ“„ useEffect.md
useLayoutEffect Synchronous DOM effects πŸ“„ useLayoutEffect.md
useRef References & imperatives πŸ“„ useRef.md
useContext Context consumption πŸ“„ useContext.md
useReducer Complex state logic πŸ“„ useReducer.md

⚑ Performance & Optimization

Hook Description Documentation Link
useMemo Value memoization πŸ“„ useMemo.md
useCallback Function memoization πŸ“„ useCallback.md
useId Unique identifier generation πŸ“„ useId.md

πŸ”§ Advanced & Imperative

Hook Description Documentation Link
useImperativeHandle Imperative APIs πŸ“„ useImperativeHandle.md
useTransition Concurrent rendering πŸ“„ useTransition.md
useDeferredValue Deferred updates πŸ“„ useDeferredValue.md

πŸ†• React 19 Form Hooks

Hook Description Documentation Link
useActionState Form action state management πŸ“„ useActionState.md
useFormStatus Form submission status πŸ“„ useFormStatus.md
useOptimistic Optimistic UI updates πŸ“„ useOptimistic.md

πŸ› οΈ Custom Hooks

Topic Description Documentation Link
Custom Hooks Patterns for reusable logic πŸ“„ customHooks.md

πŸ“š Additional Resources

Resource Description Link
Overview All hooks with beautiful cards πŸ“„ Hooks Overview
Homepage Documentation site homepage πŸ“„ Homepage

πŸ—οΈ Repository Structure

react-hooks/
β”œβ”€β”€ πŸ“ docs/                          # VitePress Documentation Site
β”‚   β”œβ”€β”€ πŸ“ .vitepress/                # VitePress configuration
β”‚   β”‚   β”œβ”€β”€ πŸ“„ config.ts              # Site config, navigation, SEO
β”‚   β”‚   └── πŸ“ theme/                 # Custom theme
β”‚   β”‚       β”œβ”€β”€ πŸ“„ index.ts           # Theme entry point
β”‚   β”‚       └── πŸ“„ custom.css         # Custom styling (cards, gradients, etc.)
β”‚   β”œβ”€β”€ πŸ“ hooks/                     # Hook documentation
β”‚   β”‚   β”œβ”€β”€ πŸ“„ index.md               # Hooks overview with beautiful cards
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 01_useState.md         # State management hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 02_useEffect.md        # Side effects hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 03_useLayout.md        # Layout effect hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 04_useRef.md           # Reference hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 05_useContext.md       # Context consumption hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 06_useReducer.md       # State reducer hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 07_useMemo.md          # Memoization hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 08_useCallback.md      # Callback memoization hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 09_useImperativeHandle.md  # Imperative API hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 10_useId.md            # Unique ID generation hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 11_useTransition.md    # Concurrent rendering hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 12_useDeferredValue.md # Deferred value hook
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 13_useActionState.md   # Form action state hook (React 19)
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 14_useFormStatus.md    # Form status hook (React 19)
β”‚   β”‚   β”œβ”€β”€ πŸ“„ 15_useOptimistic.md    # Optimistic updates hook (React 19)
β”‚   β”‚   └── πŸ“„ 16_customHooks.md      # Custom hooks patterns
β”‚   β”œβ”€β”€ πŸ“ public/                    # Static assets for docs
β”‚   β”‚   └── πŸ“„ logo.svg               # React logo
β”‚   └── πŸ“„ index.md                   # Homepage with hero section
β”œβ”€β”€ πŸ“ src/                           # React Application Source
β”‚   β”œβ”€β”€ πŸ“ hooks/                     # Hook implementations & examples
β”‚   β”‚   └── πŸ“ useState/              # useState examples
β”‚   β”‚       β”œβ”€β”€ πŸ“„ UseState.tsx       # Main useState component
β”‚   β”‚       └── πŸ“ examples/          # Practical examples
β”‚   β”‚           β”œβ”€β”€ πŸ“„ CounterBasic.tsx    # Basic counter
β”‚   β”‚           └── πŸ“„ LazyInit.tsx        # Lazy initialization
β”‚   β”œβ”€β”€ πŸ“„ App.tsx                    # Main React application
β”‚   β”œβ”€β”€ πŸ“„ App.css                    # Application styles
β”‚   β”œβ”€β”€ πŸ“„ main.tsx                   # React app entry point
β”‚   β”œβ”€β”€ πŸ“„ index.css                  # Global styles
β”‚   └── πŸ“„ vite-env.d.ts             # Vite type definitions
β”œβ”€β”€ πŸ“ public/                        # React app static assets
β”‚   └── πŸ“„ vite.svg                   # Vite logo
β”œβ”€β”€ πŸ“„ package.json                   # Dependencies & scripts
β”œβ”€β”€ πŸ“„ vite.config.ts                 # Vite configuration
β”œβ”€β”€ πŸ“„ tsconfig.json                  # TypeScript configuration
β”œβ”€β”€ πŸ“„ tsconfig.app.json              # App-specific TypeScript config
β”œβ”€β”€ πŸ“„ tsconfig.node.json             # Node.js TypeScript config
β”œβ”€β”€ πŸ“„ eslint.config.js               # ESLint configuration
β”œβ”€β”€ πŸ“„ index.html                     # React app HTML template
└── πŸ“„ README.md                      # This file

πŸ‘¨β€πŸ’» Author

Ayush Gupta


Made with ❀️ for the React community

Star ⭐ this repository if it helped you learn React Hooks!

About

React Hooks Notes β€” Concise explanations + runnable .tsx examples + VitePress docs πŸ“–βš›οΈ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published