diff --git a/beta/src/content/apis/react/useInsertionEffect.md b/beta/src/content/apis/react/useInsertionEffect.md index 4b486f9e..c77d507a 100644 --- a/beta/src/content/apis/react/useInsertionEffect.md +++ b/beta/src/content/apis/react/useInsertionEffect.md @@ -2,27 +2,144 @@ title: useInsertionEffect --- - - -This section is incomplete, please see the old docs for [useInsertionEffect.](https://reactjs.org/docs/hooks-reference.html#useinsertioneffect) + - +`useInsertionEffect` is aimed at CSS-in-JS library authors. Unless you are working on a CSS-in-JS library and need a place to inject the styles, you probably want [`useEffect`](/apis/react/useEffect) or [`useLayoutEffect`](/apis/react/useLayoutEffect) instead. + -The signateure 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`. Since this hook is limited in scope, this hook does not have access to refs and cannot schedule updates. +`useInsertionEffect` is a version of [`useEffect`](/apis/react/useEffect) that fires before any DOM mutations. ```js -useInsertionEffect(didUpdate); +useInsertionEffect(setup, dependencies?) ``` +--- + +## Usage {/*usage*/} + +### Injecting dynamic styles from CSS-in-JS libraries {/*injecting-dynamic-styles-from-css-in-js-libraries*/} + +Traditionally, you would style React components using plain CSS. + +```js +// In your JS file: +