1.0.5 • Published 5 years ago
@react-typed-hooks/use-window-size v1.0.5
useWindowSize
React hook that returns the window size. Updates on window resize and orientation change.
Installation
npm install @react-typed-hooks/use-window-size
Usage
import { useWindowSize } from "@react-typed-hooks/use-window-size";
const Demo = () => {
const size = useWindowSize();
return size ? (
<pre>JSON.stringify(size, null, 4)</pre>
) : (
<span>Size is null in a node like environment</span>
);
};
API
Types
interface Size {
height: number;
width: number;
}
interface UseWindowSizeOptions {
wait?: number;
}
function useWindowSize(options?: UseWindowSizeOptions): Size | null;
Options
wait
The amount of time to delay updating Size
after the orientation changes.
The amount of time to throttle between updating Size
when the window is resized.
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
1.0.0-alpha.3
5 years ago
1.0.0-alpha.2
5 years ago
1.0.0-alpha.0
5 years ago
0.1.1-alpha.0
5 years ago