Um hook para receber, em tempo real, os tamanhos horizontal e vertical da tela.
- npm:
npm install use-window-dimensions
- yarn:
yarn add use-window-dimensions
import React from 'react';
import useWindowDimension from 'use-window-dimensions';
const Component: React.FC = () => {
const { width, height } = useWindowDimensions();
console.log("width: " + width + "height: " + height);
return (
<div>
<h1>Height: {width} | Width: {height}</h1>
</div>
);
}