49 lines
1.7 KiB
Markdown
Executable File
49 lines
1.7 KiB
Markdown
Executable File
<hr>
|
|
<div align="center">
|
|
<h1 align="center">
|
|
usePassiveLayoutEffect()
|
|
</h1>
|
|
</div>
|
|
|
|
<p align="center">
|
|
<a href="https://bundlephobia.com/result?p=@react-hook/passive-layout-effect">
|
|
<img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/@react-hook/passive-layout-effect?style=for-the-badge&labelColor=24292e">
|
|
</a>
|
|
<a aria-label="Types" href="https://www.npmjs.com/package/@react-hook/passive-layout-effect">
|
|
<img alt="Types" src="https://img.shields.io/npm/types/@react-hook/passive-layout-effect?style=for-the-badge&labelColor=24292e">
|
|
</a>
|
|
<a aria-label="Build status" href="https://travis-ci.com/jaredLunde/react-hook">
|
|
<img alt="Build status" src="https://img.shields.io/travis/com/jaredLunde/react-hook?style=for-the-badge&labelColor=24292e">
|
|
</a>
|
|
<a aria-label="NPM version" href="https://www.npmjs.com/package/@react-hook/passive-layout-effect">
|
|
<img alt="NPM Version" src="https://img.shields.io/npm/v/@react-hook/passive-layout-effect?style=for-the-badge&labelColor=24292e">
|
|
</a>
|
|
<a aria-label="License" href="https://jaredlunde.mit-license.org/">
|
|
<img alt="MIT License" src="https://img.shields.io/npm/l/@react-hook/passive-layout-effect?style=for-the-badge&labelColor=24292e">
|
|
</a>
|
|
</p>
|
|
|
|
<pre align="center">npm i @react-hook/passive-layout-effect</pre>
|
|
<hr>
|
|
|
|
A React hook that uses `useEffect()` on the server and `useLayoutEffect()` in the browser
|
|
|
|
## Quick Start
|
|
|
|
```jsx harmony
|
|
import useLayoutEffect from '@react-hook/passive-layout-effect'
|
|
|
|
const Component = ({foo, bar}) => {
|
|
// Used the same way useEffect() and useLayoutEffect() are
|
|
useLayoutEffect(() => {}, [foo, bar])
|
|
}
|
|
```
|
|
|
|
## Full credit to
|
|
|
|
[Dan Abramov](https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85)
|
|
|
|
## LICENSE
|
|
|
|
MIT
|