npm.io
1.2.1 • Published 5 years ago

@react-hook/passive-layout-effect

Licence
MIT
Version
1.2.1
Deps
0
Size
11 kB
Vulns
0
Weekly
0
Stars
1.5K

usePassiveLayoutEffect()

Bundlephobia Types Build status NPM Version MIT License

npm i @react-hook/passive-layout-effect

A React hook that uses useEffect() on the server and useLayoutEffect() in the browser

Quick Start

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

LICENSE

MIT

Keywords