A React hook that tracks the current window dimensions.

This hook listens for the window's resize event and returns an object with the current width and height of the browser window. It updates automatically whenever the window is resized.

// Usage in a functional component:
import { useWindowSize } from "essential-hooks-collection";

const MyComponent = () => {
const { width, height } = useWindowSize();

return (
<div>
<p>Window width: {width}</p>
<p>Window height: {height}</p>
</div>
);
};

export default MyComponent;
  • Returns { height: number; width: number }

    An object containing the current window width and height.