$ npm install react-layout-effect
Tiny package dedicated to an isomorphic useLayoutEffect.
More info: https://github.com/reduxjs/react-redux/pull/1444
import { useLayoutEffect } from 'react-layout-effect'
const MyComponent = () => {
useLayoutEffect(() => {
console.log('hi')
})
}
The "hi" message is only logged when 1+ of these is true:
window.document.createElement existsThe warning message thrown by React is avoided in SSR environments.
© 2010 - cnpmjs.org x YWFE | Home | YWFE