web-api-hooks
Version:
Essential set of React Hooks for convenient Web API consumption.
13 lines (12 loc) • 304 B
TypeScript
/**
* Tracks window size.
*
* @returns Dimensions `[width, height]`, falling back to `[0, 0]` when unavailable.
*
* @example
* function Component() {
* const [windowWidth, windowHeight] = useWindowSize();
* // ...
* }
*/
export default function useWindowSize(): Readonly<[number, number]>;