Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ const selectedField = useSyncExternalStore(
useInsertionEffect(didUpdate);
```

TODO: description
The signature is identical to `useEffect`, but it fires synchronously _before_ all DOM mutations. Use this to inject styles into the DOM before reading layout in [`useLayoutEffect`](#uselayouteffect). Since this hook is limited in scope, this hook does not have access to refs and cannot schedule updates.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it currently warn if you update state in useInsertionEffect or are updates during this phase just dropped?

Copy link
Member

@acdlite acdlite Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should warn but it doesn't currently. Want to submit a PR?


> Note:
>
> TODO: no refs
>
> `useInsertionEffect` should be limited to css-in-js library authors. Prefer [`useEffect`](#useeffect) or [`useLayoutEffect`](#uselayouteffect) instead.