UNPKG

@darwish/hooks-core

Version:

16 lines (15 loc) 472 B
import { useState } from "react"; import useEventListener from "./useEventListener"; export default function useWindowSize() { var _a = useState({ width: window.innerWidth, height: window.innerHeight, }), windowSize = _a[0], setWindowSize = _a[1]; useEventListener(window, "resize", function () { setWindowSize({ width: window.innerWidth, height: window.innerHeight, }); }); return windowSize; }