0.3.0 • Published 1 year ago

react-hooks-window-size v0.3.0

Weekly downloads
272
License
MIT
Repository
github
Last release
1 year ago

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