Generate a library of reusable React custom hooks with TypeScript
Create a collection of React custom hooks for:
Use Cases: {{USE_CASES}} (e.g., data fetching, forms, animations, browser APIs)
TypeScript: Yes
Testing: {{INCLUDE_TESTS}} (yes/no)
Generate the following hooks with full implementations:
1. **Data Fetching:**
- useFetch<T> - Generic fetch with loading/error states
- useInfiniteScroll - Pagination with intersection observer
- useDebounce<T> - Debounced value updates
- useThrottle<T> - Throttled value updates
2. **Form Handling:**
- useForm<T> - Form state management
- useField - Individual field management
- useValidation - Schema-based validation
- useFormPersist - Persist form to storage
3. **Browser APIs:**
- useLocalStorage<T> - Synced localStorage
- useSessionStorage<T> - Synced sessionStorage
- useMediaQuery - Responsive breakpoints
- useGeolocation - Location tracking
- useClipboard - Copy/paste functionality
- useOnline - Network status
4. **UI/UX:**
- useModal - Modal state management
- useToast - Toast notifications
- useClickOutside - Outside click detection
- useKeyPress - Keyboard shortcuts
- useHover - Hover state tracking
- useFocus - Focus management
5. **Performance:**
- useMemoCompare - Deep comparison memo
- usePrevious<T> - Previous value tracking
- useRenderCount - Debug render counts
- useWhyDidYouUpdate - Props change tracking
Include TypeScript interfaces, JSDoc comments, and usage examples.Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{USE_CASES][{INCLUDE_TESTS]