#react Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
TypeScript useEventListener — Typed Wrapper
A type-safe useEventListener for window, document, or any element ref. Picks the right event-map automatically so the handler argument is correctly typed (MouseEvent, KeyboardEvent, etc.).
TypeScript useFetch — Minimal Data Fetching Hook
A tiny self-contained data-fetching hook with loading/error/data states and AbortController cleanup on unmount. Good baseline before reaching for TanStack Query.
TypeScript useDebounce — Debounced State
A React hook that returns a debounced version of any value. Trigger expensive effects (search, autosave, network fetches) on this value instead of the raw input.
TypeScript useLocalStorage — Synced State
A useState replacement that persists to localStorage and syncs across tabs via the `storage` event. Strongly typed via the initial value's type.
TypeScript useMediaQuery — Responsive Hook
Subscribe to a CSS media query (e.g. dark mode, viewport size) from React. Re-renders when the match changes. SSR-safe — returns `false` on the server.
TypeScript useClickOutside — Detect Outside Clicks
Fire a callback when the user clicks anywhere outside a referenced element. Perfect for closing dropdowns, popovers, and modal-less menus.
TypeScript usePrevious — Track Last Render's Value
Returns the value the prop/state had on the previous render. Useful for detecting transitions (e.g. "the count just went from 0 to 1") inside effects.