RReactUseinreactuse.hashnode.dev·Aug 21 · 12 min readReact useTimeout Hook: Declarative setTimeout with Cleanup (2026)Here is a "Copied!" button. Every codebase has one, and this version has three bugs: function CopyButton({ text }: { text: string }) { const [copied, setCopied] = useState(false); useEffect(() =>00
RReactUseinreactuse.hashnode.dev·Aug 20 · 12 min readReact useEventListener Hook: Type-Safe DOM Events (2026)Here's a modal close-on-Escape that quietly does the wrong thing: function Modal({ onClose }: { onClose: () => void }) { useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key =00
RReactUseinreactuse.hashnode.dev·Aug 19 · 13 min readReact useScrollLock Hook: Lock Body Scroll for Modals (2026)Your modal is open, centered, perfect. Then someone flicks the overlay and the page behind it scrolls away underneath. Everyone's first fix is the same three lines: useEffect(() => { document.body.s00
RReactUseinreactuse.hashnode.dev·Aug 18 · 13 min readReact scrollIntoView with useRef: Scroll to an Element (2026)You have a long form. The user hits Submit, validation fails on a field three screens down, and the error message renders somewhere they can't see. The fix is one browser API call — but where you put 00
RReactUseinreactuse.hashnode.dev·Aug 17 · 13 min readReact useSessionStorage Hook: Per-Tab State That Survives Reloads (2026)React useSessionStorage Hook: Per-Tab State That Survives Reloads (2026) Here's a checkout flow that loses the customer at step three: function Checkout() { const [step, setStep] = useState(0); co00