@realdennis/use-resize

React hook for window resize using use-event-target.

Usage no npm install needed!

<script type="module">
  import realdennisUseResize from 'https://cdn.skypack.dev/@realdennis/use-resize';
</script>

README

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.