React usePrevious Hook: Track Previous State & Props (2026)

React gives you the current value of state and props on every render — and no built-in way to ask what the value was before. So everyone copies the same ten-line recipe: stash the value in a ref inside useEffect, return ref.current. It works in the demo, ships to production, and then one day a "count went up ↑" indicator starts claiming nothing changed — because the component re-rendered for a completely unrelated reason and the ref quietly overwrote its own history.

usePrevious from @reactuses/core tracks the previous distinct value instead of the previous render's value, using the pattern the React docs themselves recommend — no refs, no effects, no drift. The whole implementation is twelve lines, so this post walks through the real bug in the classic recipe, why the fix looks illegal but isn't, and the one gotcha that can send it into an infinite loop. TypeScript-first.

The Classic Recipe, and Where It Frays

This is the version that lives in a thousand blog posts and probably a few of your codebases: