1.7.0 • Published 2 years ago

@charlietango/use-window-size v1.7.0

Weekly downloads
503
License
MIT
Repository
github
Last release
2 years ago

useWindowSize

Get the width and height of the viewport.

Checkout the Storybook demo.

Installation

yarn add @charlietango/use-window-size

API

const { width, height } = useWindowSize()

By default, the value is lazy to support SSR, so the width and height will always be 0 on the initial render. Subsequent users of the hook will return the size during the first render.

Example

import React from 'react'
import useWindowSize from '@charlietango/use-window-size'

const Component = () => {
  const { width, height } = useWindowSize()

  return (
    <div>
      {width}x{height}px
    </div>
  )
}

export default Component
1.7.0

2 years ago

1.6.0

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.5

4 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago