amendezm / use-window-dimensions

Custom react hook to get current window dimensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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>
  );
};

About

Custom react hook to get current window dimensions


Languages

Language:JavaScript 54.6%Language:TypeScript 45.4%