useWindowSize ​
Hook that manages a window size
elements
test coverage
Last changed: last month
Installation ​
Library
CLI
Manual
typescript
import { useWindowSize } from '@siberiacancode/reactuse';
Usage ​
typescript
const { width, height } = useWindowSize();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
params.initialWidth? | number | Number.POSITIVE_INFINITY | The initial window width |
params.initialHeight? | number | Number.POSITIVE_INFINITY | The initial window height |
Returns
UseWindowSizeReturn
Type declaration ​
typescript
interface UseWindowSizeParams {
/** Whether to include the scrollbar in the window size calculation */
includeScrollbar?: boolean;
}
export interface UseWindowSizeReturn {
/** The current window height */
height: number;
/** The current window width */
width: number;
}
Source ​
Source • DemoContributors ​
D
H