@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
14 lines (13 loc) • 493 B
JavaScript
"use client";
import { useEffect, useEffectEvent } from "react";
//#region packages/@mantine/hooks/src/use-window-event/use-window-event.ts
function useWindowEvent(type, listener, options) {
const stableListener = useEffectEvent(listener);
useEffect(() => {
window.addEventListener(type, stableListener, options);
return () => window.removeEventListener(type, stableListener, options);
}, [type]);
}
//#endregion
export { useWindowEvent };
//# sourceMappingURL=use-window-event.mjs.map