useWindowResize()
Receive a callback function to execute on the window's resize event.
Usage
Default behaviour is to execute the callback function on every resize event.
import { useWindowResize } from '@norr/hooks';
const Component = () => {
useWindowResize((event) => {
console.log(event);
});
return null;
};
Performance
To enhance performance you can pass a debounce number (in milliseconds) as the second argument. This will delay the callback function until the user has stopped resizing the window for the given amount of time.
import { useWindowResize } from '@norr/hooks';
const Component = () => {
const debounce = 250;
useWindowResize((event) => {
console.log(event);
}, debounce);
return null;
};