Loading homepage
Build a React hook that returns the current viewport width and height and keeps them synchronized with window resize events.
JavaScript and TypeScript use the same contract. Tests render real React components and cover state updates and lifecycle behavior.
Input: window.innerWidth = 1280 and window.innerHeight = 720 Output: Returns { width: 1280, height: 720 }.
Input: Window resizes to 800 by 600 Output: Next state is { width: 800, height: 600 }.
Input: Render on a server without window Output: Returns { width: undefined, height: undefined }.
Examples describe state after the corresponding React render or update.