Course contentsShow
← React
Lesson 619 of 2,39617. Common useEffect MistakesFree lesson

The useEffectEvent Proposal (React Labs)

React is exploring useEffectEvent to access latest values without adding them to dependencies.

The useEffectEvent Hook

You'll learn how to access the latest values in effects without triggering re-runs.

The Problem This Solves

You've seen two patterns for handling functions in effects: wrapping them with useCallback (which adds complexity) or moving them inside the effect (which can make code messy). Both approaches force you to treat these functions as dependencies, causing effects to re-run whenever they change.

But what if you have a function that uses the latest props or state, yet you don't want it to trigger effect re-runs?

What useEffectEvent Does

useEffectEvent is a stable React Hook introduced in React 19.2 (October 2025). It lets you create a special kind of function that:

  • Always sees the latest props and state (no stale closures)
  • Doesn't need to be a dependency
  • Won't trigger effect re-runs when it changes

Think of it like a magic bridge: your effect can call this function anytime, and it will always use fresh values, but React won't consider it "changed" for dependency purposes. This eliminates many awkward useCallback chains and makes effects much cleaner.

The Mental Model

Imagine a logbook that's always updated with the latest ship coordinates, but reading the logbook doesn't trigger a new voyage. That's useEffectEvent: it provides current information without causing re-synchronization.

By using this hook, you can effectively separate the "when" from the "what." The useEffect continues to manage when an action should occur based on its specific dependency array, while the useEffectEvent manages what logic to run using the absolute most recent state and props.

Key Takeaway: The stable useEffectEvent Hook lets you access the latest values inside effects without adding them to dependencies, solving the function-dependency problem in a more elegant way than useCallback.