What is React?
- For Beginners
- How We Use It
React is a JavaScript library for building user interfaces, created by Facebook (now Meta). Think of it as a way to build interactive websites using reusable pieces called “components.”Key Concepts:Instead of manually manipulating the DOM, you describe what the UI should look like, and React handles the updates.
- Components: Building blocks of your UI (like LEGO pieces)
- State: Data that can change over time (like a counter value)
- Props: Data passed from parent to child components (like function arguments)
- JSX: HTML-like syntax inside JavaScript
- Build once, reuse everywhere (components)
- Automatically updates UI when data changes
- Huge ecosystem and community
- Used by Facebook, Instagram, Netflix, Airbnb, and thousands more
Essential React Concepts
1. Components
- Function Components
- Class Components (Legacy)
2. State Management
3. Effects & Side Effects
4. Props & Prop Drilling
5. Context API (Avoid Prop Drilling)
100 Essential React Terms
Core Concepts (1-20)
Core Concepts (1-20)
- Component - Reusable UI building block
- JSX - JavaScript XML syntax
- Props - Data passed to components
- State - Component’s internal data
- Virtual DOM - In-memory representation of UI
- Reconciliation - Process of updating the DOM
- Rendering - Converting components to UI
- Re-rendering - Updating UI when data changes
- Mount - Component added to DOM
- Unmount - Component removed from DOM
- Lifecycle - Stages of component existence
- Key - Unique identifier for list items
- Ref - Reference to DOM element
- Fragment - Group elements without wrapper
- Children - Components/elements inside component
- Composition - Building complex UIs from simple components
- Pure Component - Component with no side effects
- Controlled Component - Form input controlled by React state
- Uncontrolled Component - Form input managed by DOM
- Synthetic Event - React’s cross-browser event wrapper
Hooks (21-40)
Hooks (21-40)
- useState - State management hook
- useEffect - Side effects hook
- useContext - Context consumption hook
- useReducer - Complex state management
- useCallback - Memoize functions
- useMemo - Memoize computed values
- useRef - Persist values across renders
- useLayoutEffect - Synchronous useEffect
- useImperativeHandle - Customize ref exposure
- useDebugValue - Debug custom hooks
- useTransition - Non-blocking updates (React 18)
- useDeferredValue - Defer expensive updates
- useId - Generate unique IDs
- useSyncExternalStore - Subscribe to external stores
- useInsertionEffect - CSS-in-JS libraries
- Custom Hook - Reusable stateful logic
- Hook Rules - Rules of Hooks (top-level only, etc.)
- Dependency Array - useEffect/useCallback dependencies
- Stale Closure - Outdated values in closures
- Hook Flow - Order of hook execution
Advanced Patterns (41-60)
Advanced Patterns (41-60)
- Higher-Order Component (HOC) - Function that wraps components
- Render Props - Share code using props
- Compound Components - Components that work together
- Controlled Props - Props that control state
- State Reducer Pattern - Inversion of control for state
- Provider Pattern - Context provider pattern
- Container/Presentational - Logic/UI separation
- Lifting State Up - Move state to common ancestor
- Prop Drilling - Passing props through many levels
- Code Splitting - Load code on demand
- Lazy Loading - Defer component loading
- Suspense - Handle async operations
- Error Boundary - Catch React errors
- Portal - Render outside parent DOM
- Forwarding Refs - Pass refs to child components
- Memoization - Cache expensive computations
- Batching - Group state updates
- Concurrent Rendering - Interruptible rendering
- Automatic Batching - Batch updates everywhere (React 18)
- Transitions - Mark updates as non-urgent
Performance (61-75)
Performance (61-75)
- React.memo - Prevent unnecessary re-renders
- shouldComponentUpdate - Lifecycle optimization (legacy)
- PureComponent - Shallow prop comparison (legacy)
- Profiler - Measure render performance
- Windowing - Render only visible items
- Debouncing - Delay function execution
- Throttling - Limit function calls
- Virtualization - Render large lists efficiently
- Web Workers - Offload heavy computations
- Bundle Size - JavaScript file size
- Tree Shaking - Remove unused code
- Code Splitting - Split into chunks
- Prefetching - Load resources early
- Hydration - Attach React to SSR HTML
- Streaming SSR - Progressive rendering
State Management (76-85)
State Management (76-85)
- Local State - Component-specific state
- Global State - Application-wide state
- Server State - Data from API
- URL State - State in URL params
- Redux - Predictable state container
- Zustand - Lightweight state management
- Jotai - Atomic state management
- Recoil - Facebook’s state library
- MobX - Observable state
- XState - State machines
Next.js Specifics (86-100)
Next.js Specifics (86-100)
- Server Component - Runs on server (Next.js)
- Client Component - Runs in browser
- Server Actions - Server-side functions
- App Router - File-based routing (Next.js 13+)
- Pages Router - Legacy routing (Next.js)
- Layout - Shared UI across routes
- Loading.tsx - Loading states
- Error.tsx - Error handling
- Route Handlers - API routes
- Middleware - Request interception
- Static Generation (SSG) - Pre-render at build
- Server-Side Rendering (SSR) - Pre-render per request
- Incremental Static Regeneration (ISR) - Update static pages
- Dynamic Routes - [param] based routes
- Parallel Routes - Multiple pages at once
Common Libraries & Tools
Data Fetching
- TanStack Query (React Query) - Server state management
- SWR - Stale-while-revalidate
- Axios - HTTP client
- GraphQL - Query language
- tRPC - Type-safe APIs
State Management
- Zustand - Lightweight, our go-to
- Redux Toolkit - Redux simplified
- Jotai - Atomic state
- Context API - Built-in React
Forms
- React Hook Form - Performant forms
- Zod - Schema validation
- Yup - Validation library
- Formik - Form management (legacy)
UI Components
- shadcn/ui - Copy-paste components
- Radix UI - Headless components
- Headless UI - Tailwind components
- Chakra UI - Component library
Styling
- Tailwind CSS - Utility-first CSS
- CSS Modules - Scoped styles
- Styled Components - CSS-in-JS
- Emotion - CSS-in-JS
Animation
- Framer Motion - Animation library
- React Spring - Spring physics
- GSAP - Professional animations
Routing
- React Router - Client-side routing
- TanStack Router - Type-safe routing
- Next.js Router - Built-in (Next.js)
Testing
- Vitest - Unit testing
- Jest - Testing framework
- React Testing Library - Component testing
- Playwright - E2E testing
File Structure & Project Organization
Next.js + React Structure
Vite + React Structure
Understanding File-Based Routing (Next.js)
1
Basic Routes
Files create routes automatically:
2
Dynamic Routes
Use square brackets for parameters:
3
Route Groups
Use parentheses to organize without affecting URLs:
4
Special Files
Debugging React Applications
1. React DevTools
2. Common Debugging Patterns
3. Performance Debugging
Testing Commands
Next.js + React
Vite + React
Common Issues & Solutions
'React' must be in scope when using JSX
'React' must be in scope when using JSX
Problem: Old React versions required importing ReactSolution:
Cannot update during render
Cannot update during render
Problem: Setting state during render causes infinite loopSolution:
useEffect infinite loop
useEffect infinite loop
Problem: Missing or wrong dependenciesSolution:
'this' is undefined
'this' is undefined
Problem: Arrow functions vs regular functionsSolution:
Key prop warning in lists
Key prop warning in lists
Problem: Missing unique key for list itemsSolution:
Stale closure in useEffect
Stale closure in useEffect
Problem: Function captures old valuesSolution:
Best Practices Checklist
1
Component Design
- Use functional components with hooks
- Keep components small and focused
- Separate logic from presentation
- Use TypeScript for type safety
- Extract reusable logic into custom hooks
2
State Management
- Start with local state (useState)
- Lift state up when needed
- Use Context for app-wide state
- Use Zustand/Redux for complex global state
- Keep state as close to where it’s used as possible
3
Performance
- Use React.memo for expensive components
- Memoize callbacks with useCallback
- Memoize computed values with useMemo
- Code split with React.lazy
- Virtualize long lists
4
Error Handling
- Wrap components in Error Boundaries
- Handle async errors in useEffect
- Validate props with TypeScript
- Show user-friendly error messages
5
Testing
- Write tests for critical paths
- Test user behavior, not implementation
- Use React Testing Library
- Mock API calls
- Test accessibility

