use-screen-dimensions
v1.2.0
Published
custom react hook to get current window dimensions
Downloads
1,896
Readme
Hook use-screen-dimensions
Custom react hook to get current window/screen dimensions
Installation
- npm:
npm install use-screen-dimensions
- yarn:
yarn add use-screen-dimensions
How to use
import React from "react";
import {useScreenDimensions} from "use-screen-dimensions";
const Component: React.FC = () => {
const { width, height } = useScreenDimensions();
console.log("width: " + width + "height: " + height);
return (
<div>
<h1>
Height: {width} | Width: {height}
</h1>
</div>
);
};