Skip to content

Commit 13e5c04

Browse files
committed
feedback
1 parent 65bbdb0 commit 13e5c04

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/content/reference/react/hooks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ There are two rarely used variations of `useEffect` with differences in timing:
7979
* [`useLayoutEffect`](/reference/react/useLayoutEffect) fires before the browser repaints the screen. You can measure layout here.
8080
* [`useInsertionEffect`](/reference/react/useInsertionEffect) fires before React makes changes to the DOM. Libraries can insert dynamic CSS here.
8181
82+
You can also separate events from Effects:
83+
84+
- [`useEffectEvent`](/reference/react/useEffectEvent) creates a non-reactive event to fire from any Effect hook.
8285
---
8386
8487
## Performance Hooks {/*performance-hooks*/}

src/content/reference/react/useEffectEvent.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const onEvent = useEffectEvent(callback)
2020

2121
### `useEffectEvent(callback)` {/*useeffectevent*/}
2222

23-
Call `useEffectEvent` at the top level of your component to declare an Effect Event.
23+
Call `useEffectEvent` at the top level of your component to create an Effect Event.
2424

2525
```js {4,6}
2626
import { useEffectEvent, useEffect } from 'react';
@@ -32,7 +32,7 @@ function ChatRoom({ roomId, theme }) {
3232
}
3333
```
3434

35-
Effect Events are functions you can call inside Effects, such as `useEffect`.
35+
Effect Events are a part of your Effect logic, but they behave more like an event handler. They always “see” the latest values of your props and state without re-synchronizing your Effect, so they're excluded from Effect dependencies. See [Separating Events from Effects](/learn/separating-events-from-effects#extracting-non-reactive-logic-out-of-effects) to learn more.
3636

3737
[See more examples below.](#usage)
3838

@@ -70,7 +70,7 @@ This is a deliberate design choice. Effect Events are meant to be called only fr
7070

7171
The non-stable identity acts as a runtime assertion: if your code incorrectly depends on the function identity, you'll see the Effect re-running on every render, making the bug obvious.
7272

73-
This design reinforces the rule that Effect Events are "escape hatches" for reading the latest values, not general purpose callbacks to be passed around.
73+
This design reinforces that Effect Events conceptually belong to a particular effect, and are not a general purpose API to opt-out of reactivity.
7474

7575
</DeepDive>
7676

0 commit comments

Comments
 (0)