**To Run Application
git clone git@github.com:rajkumar4041/react-advance.git
cd react-advance
npm install
npm run dev
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
- React Context API
- Custom Hooks
- React.lazy & Suspense (Code Splitting)
- Error Boundaries
- Refs and Imperative Handle
- Higher-Order Components (HOC)
- Compound Components Pattern
- startTransition (Concurrent Features)
- Render Props
This project demonstrates several advanced React concepts. Below is a list of topics, a brief explanation of each, and where they are implemented in this application:
-
React Context API
- What: Provides a way to share state globally across the component tree without prop drilling.
- Where: Implemented via
TaskProviderand accessed with theuseTaskscustom hook. (Seecontext/TaskContextandhooks/useTasks).
-
Custom Hooks
- What: Encapsulate reusable logic that can be shared across components.
- Where:
useTasksmanages task state and logic. (Seehooks/useTasks).
-
React.lazy & Suspense (Code Splitting)
- What: Dynamically load components to optimize performance and reduce initial bundle size.
- Where:
TaskStatsis loaded withReact.lazyand rendered inside aSuspenseboundary. (SeeApp.tsx).
-
Error Boundaries
- What: Catch JavaScript errors in child components and display a fallback UI.
- Where: The
ErrorBoundarycomponent wrapsTaskStatsto handle errors gracefully. (Seecomponents/ErrorBoundaryandApp.tsx).
-
Refs and Imperative Handle
- What: Access and control child components imperatively from parent components.
- Where:
AddTaskModaluses arefto expose afocusInputmethod, allowing the parent to focus the input programmatically. (Seecomponents/AddTaskModalandApp.tsx).
-
Higher-Order Components (HOC)
- What: Functions that take a component and return a new component with enhanced behavior.
- Where:
withLoggerwrapsTaskListto add logging functionality. (Seecomponents/withLoggerandApp.tsx).
-
Compound Components Pattern
- What: Components that work together via shared state/context, providing a flexible API.
- Where: The
Togglecomponent exposesToggle.On,Toggle.Off, andToggle.Buttonas compound components. (Seecomponents/CustomToggleandApp.tsx).
-
startTransition (Concurrent Features)
- What: Schedules state updates with lower priority to keep the UI responsive during heavy updates.
- Where: Used in
handleFilterto filter tasks without blocking the UI. (SeeApp.tsx).
-
Render Props
- What: A technique for sharing code between components using a function as a child.
- Where:
FilterTasksuses a render prop to pass filtered tasks toTaskListWithLogger. (Seecomponents/FilterTasksandApp.tsx).