JSPM

  • Created
  • Published
  • Downloads 86
  • Score
    100M100P100Q99454F

A React hook for window on resize event

Package Exports

  • @rooks/use-on-window-resize

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 (@rooks/use-on-window-resize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rooks/use-on-window-resize

A React hook for adding an event listener for window resize


Build Status

Join the community on Spectrum

Installation

npm install --save @rooks/use-on-window-resize

Importing the hook

import useOnWindowResize from "@rooks/use-on-window-resize"

Usage

function Demo() {
  useOnWindowResize(() => console.log("window resized"))
  return <p> Hello world </p>
}

render(<Demo/>)

Arguments

Arguments Type Description Default value
callback function Callback function which needs to run on unmount undefined
when boolean When the event handler should be active true

A React hook for adding an event listener for window resize