# useViewportState A hook that returns relevant information on the current viewport state. It's built on top of [useWindowResize](./useWindowResize.md) and [useWindowScroll](./useWindowScroll.md). ### Why? 💡 - takes care of adding the listener for the window resize event. - takes care of removing the listener when the component will unmount ### Basic Usage: ```jsx harmony import { useState } from 'react'; import { Typography, Tag } from 'antd'; import useViewportState from 'beautiful-react-hooks/useViewportState'; const WindowSizeReporter = () => { const { width, height, scrollX, scrollY } = useViewportState(); return ( Window current properties width: {width} height: {height} horizontal scroll: {scrollX} vertical scroll: {scrollY} ); }; ``` ### Mastering the hook #### ✅ When to use - When in need of reading common information about the current viewport ### Types ```typescript static export interface ViewportState { width: number; height: number; scrollX: number; scrollY: number; } /** * Returns updated information on the current viewport state */ declare const useViewportState: (debounceBy?: number) => ViewportState; export default useViewportState; ```