@talves/use-window-size
v0.1.1
Published
React hook (useWindowSize)
Downloads
11
Readme
Installation
This module is distributed via npm which is bundled with node and
should be installed as one of your project's dependencies:
npm install --save @talves/use-window-sizeOR
yarn add @talves/use-window-sizeUsage
/* using react ^17.0.1 */
import { useEffect } form 'react'
import { useWindowSize } from '@talves/use-window-size'
import useWindowSize from '@talves/use-window-size'
function ourFunctionalComponent({ ...props }) {
const size = useWindowSize()
React.useEffect(() => {
// Do something with the size
}, [size])
...
}NOTE: This is a module package library for react using window. The choice is to resolve the import to lib/index.mjs. There is a commonjs version in dist/lib/use-window-size.js if someone needed.
Other Solutions
Plenty of other hooks out there.
