react-hooks-window-size
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

react-hooks-window-size

A react hooks approach to window resize events.

Install

yarn add react-hooks-window-size

or

npm install react-hooks-window-size

Usage Example

import React from 'react'
import { useWindowSize } from 'react-hooks-window-size'

const App: React.StatelessComponent = () => {
  const size = useWindowSize(/* 1280, 1024 */) // optionally pass in size values for server side rendering

  return (
    <p>
      The window is currently {size.width}px by {size.height}px.
    </p>
  )
}

export default App

Package Sidebar

Install

npm i react-hooks-window-size

Weekly Downloads

111

Version

0.3.0

License

MIT

Unpacked Size

10.4 kB

Total Files

9

Last publish

Collaborators

  • garthw