This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
readyornot/components/windowsize.tsx

24 lines
526 B
TypeScript

import { useEffect, useState } from "react";
export default function useWindowSize() {
const [windowSize, setWindowSize] = useState({
width: 0,
height: 0,
});
useEffect(() => {
function handleResize() {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
}
window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);
return windowSize.width <= 1080;
}