Sub topic 14
From experimental_useEffectEvent to the Stable API
You may find two import styles for Effect Events in tutorials, blog posts, and older codebases. This chapter explains where each one came from, which one to use today, and how to move code from the old one to the new one. It assumes you know the earlier chapters' material: what an Effect Event is, how it reads the latest props and state, and the rules for calling it.
A Short History
The idea started in 2022 as a proposed useEvent Hook. Its scope was then narrowed to the Effect use case and it was renamed useEffectEvent. For a long time it shipped only in React's experimental release channel, under the name experimental_useEffectEvent. The prefix meant the API could change or disappear, so production apps were discouraged from depending on it.
React 19.2, released in October 2025, made useEffectEvent a stable export of the react package. Version 6.1 of eslint-plugin-react-hooks, released around the same time, added stable support for it in the dependency lint rule.
Which Import to Use
| Your setup | Import | Notes |
|---|---|---|
| React 19.2 or later | `import { useEffectEvent } from 'react'` | The supported, stable API |
| React experimental channel, before 19.2 | `import { experimental_useEffectEvent } from 'react'` | Can change without notice |
| React 19.1 or earlier, stable channel | Not available | Upgrade React, or restructure the Effect |
The stable version follows the same rules this tutorial has covered. You call an Effect Event only from inside Effects in the same component. You never call it during render, never pass it to other components or Hooks, and never list it as a dependency.
Migrating Existing Code
Older code usually aliased the experimental name so the rest of the file could already use the final name:
import { useEffect, experimental_useEffectEvent as useEffectEvent } from 'react';With that alias in place, migrating comes down to changing the import. First upgrade the packages:
npm install react@^19.2.0 react-dom@^19.2.0
npm install --save-dev eslint-plugin-react-hooks@latestThen replace the import:
import { useEffect, useEffectEvent } from 'react';
import { createConnection } from './chat.js';
import { showNotification } from './notifications.js';
function ChatRoom({ roomId, theme }) {
const onConnected = useEffectEvent(() => {
showNotification('Connected!', theme);
});
useEffect(() => {
const connection = createConnection(roomId);
connection.on('connected', () => {
onConnected();
});
connection.connect();
return () => connection.disconnect();
}, [roomId]);
}If your code used experimental_useEffectEvent without an alias, search the codebase for that name and rename every call site.
Common Errors
useEffectEvent is not a functionor an import error: the installed React is older than 19.2. Runnpm ls reactto check which version is actually installed. A lockfile or a nested dependency can pin an older copy.- Two copies of React: if a library bundles its own older React, Hooks can fail in confusing ways. Make sure only one version of
reactappears innpm ls react. - Lint suggests adding the Effect Event as a dependency: the plugin is outdated. Upgrade it instead of suppressing the rule.
- Copying from old docs: snippets that import
experimental_useEffectEventwill not work on stable React 19.2, because the stable package exports the Hook asuseEffectEvent. Switch to that name.
Exercise
A teammate's project runs React 19.2 and has import { experimental_useEffectEvent as useEffectEvent } from 'react'. ESLint also asks them to add onTick to an Effect's dependency array. What two changes should they make?
Show answer
Change the import to import { useEffectEvent } from 'react', because the stable package exports the Hook under that name. Then upgrade eslint-plugin-react-hooks to a version that supports Effect Events (6.1 or later), so the linter stops asking for onTick as a dependency. Neither change requires editing the Effect logic.
Exercise
Your app is pinned to React 18 and cannot upgrade this quarter. Should you install the experimental channel to get experimental_useEffectEvent?
Show answer
Usually not. Experimental builds can change without notice and are not meant for production. Restructure the Effect for now, for example by passing values in as arguments or moving logic into an event handler. Adopt useEffectEvent once you upgrade to React 19.2.