Skip to Content
ohooks

useUpdateEffect

Runs a useEffect callback only on dependency updates, skipping the initial mount.

Loading preview...

The useUpdateEffect hook has the exact same signature as useEffect, but skips running the effect on initial mount and executes it only when dependencies change on subsequent renders.

Installation

pnpm dlx shadcn@latest add https://ohooks.vercel.app/r/useUpdateEffect.json

Usage

Examples

Auto-Saving Only After User Edits

Skip the initial render so loading pre-populated data does not immediately trigger a network save request.

Resetting Pagination When Filters Change

Reset the page number back to 1 whenever category changes, without resetting an initial page param on mount.