npm.io
0.0.5 • Published 7 years ago

@realdennis/use-resize

Licence
MIT
Version
0.0.5
Deps
1
Size
4 kB
Vulns
0
Weekly
0
Stars
2

useResize

Get window size by hooks resize event without side-effect.

How to use?

import useResize from '@realdennis/use-reize';
const demo = ()=>{
  const size = useResize();
  return <p>{`width: ${size.width} / height: ${size:height}`}</p>
}

What I Do?

Call clean-up function (to removeEventListener) when component has been unmounted.

Why This has a dependency of useEventTarget

This is a hooks infrastructure for easily package a event hooks.

See more useEventTarget.

Keywords