@utilityjs/use-isomorphic-layout-effect
Version:
A React hook that schedules a `React.useLayoutEffect` with a fallback to a `React.useEffect` for environments where layout effects should not be used (such as server-side rendering).
31 lines (21 loc) • 1.3 kB
Markdown
<div align="center">
<h1 align="center">
useIsomorphicLayoutEffect
</h1>
</div>
<div align="center">
A React hook that schedules a `React.useLayoutEffect` with a fallback to a `React.useEffect` for environments where layout effects should not be used (such as server-side rendering).
[](https://github.com/mimshins/utilityjs/blob/main/LICENSE)
[](https://www.npmjs.com/package/@utilityjs/use-isomorphic-layout-effect)
[](https://www.npmjs.com/package/@utilityjs/use-isomorphic-layout-effect)
[](https://www.npmjs.com/package/@utilityjs/use-isomorphic-layout-effect)
```bash
npm i @utilityjs/use-isomorphic-layout-effect | yarn add @utilityjs/use-isomorphic-layout-effect
```
</div>
<hr>
## API
### `useIsomorphicLayoutEffect(effect, deps?)`
```ts
declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
```