JSPM

react-layout-effect

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 45872
  • Score
    100M100P100Q145737F
  • License MIT

Package Exports

  • react-layout-effect

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-layout-effect) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-layout-effect

Tiny package dedicated to an isomorphic useLayoutEffect.

More info: https://github.com/reduxjs/react-redux/pull/1444

Usage

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 exists
  • using a bundler that supports ".native.js" overrides

The warning message thrown by React is avoided in SSR environments.