A collection of useful code snippets, patterns, and utilities I often use.
Create a deep copy of objects and arrays, avoiding reference issues.
Format dates consistently across your application with a simple utility function.
Generate unique identifiers for keys, temporary IDs, and unique values.
Delay execution in async functions with a sleep utility.
Copy text to clipboard with a simple React hook that handles success and error states.
Detect when an element enters or leaves the viewport using the Intersection Observer API.
Check if a component is rendering for the first time.
Track the previous value of a state or prop in React.
A React hook to throttle function calls, limiting execution frequency.
Track window dimensions for responsive design and layout calculations.
React hook to track CSS media query matches for responsive design.
A custom React hook for fetching data with loading and error states.
Truncate long strings with ellipsis, useful for previews and card layouts.
Detect clicks outside a specific element, useful for closing modals and dropdowns.
A React hook to persist state in localStorage with automatic synchronization.
A simple React hook to toggle between boolean states.
A hook to track if a component is still mounted.
A custom React hook to debounce user input.
A simple utility function to narrow unknown types in TypeScript.
Simple utility to capitalize the first letter of a string.
A utility function to ensure exhaustive checks in switch statements.