Debounce vs Throttle in React: Handling Rapid User Input
Debounce waits until rapid events pause before running code, while throttle runs code at most once per interval. Learn both patterns in React.
Build modern UIs with React
Debounce waits until rapid events pause before running code, while throttle runs code at most once per interval. Learn both patterns in React.
Make clickable elements accessible in React by using real buttons and links instead of divs with onClick. Native elements bring focus, keyboard, and roles for free.
Keyboard navigation in React uses Tab to move between components and arrow keys to move inside them. Learn the roving tabindex pattern.
Type React events and form handlers with the event types from @types/react. Most handlers infer the type, and you annotate only when extracting functions.
The dependency array is the second argument to useEffect. It tells React when to skip re-running the Effect by comparing each value with Object.is.
useEffect runs twice in development because Strict Mode mounts, unmounts, and remounts each component once. Learn why and how to make your Effect survive it.
Fetching in useEffect can apply a stale response over a newer one. Use an ignore flag in the cleanup function to drop outdated results.
Every useEffect that starts a timer, adds a listener, or opens a subscription must undo it. Return a cleanup function that mirrors the setup.
An infinite loop in useEffect happens when an Effect updates state that is also a dependency. Learn the causes and how to break the cycle.
useEffect does not accept an async function directly. Declare an async function inside the Effect, call it, and guard against stale responses in the cleanup.
useEffect runs after the browser paints, while useLayoutEffect runs after the DOM updates but before the paint. Learn which one fits each job.
Most state adjustments can happen during render or in an event handler. Learn the React patterns that replace unnecessary Effects.