mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
20 lines
494 B
TypeScript
20 lines
494 B
TypeScript
|
import { useEffect, useState } from "react";
|
||
|
|
||
|
const useSize = () => {
|
||
|
const [windowSize, setWindowSize] = useState([window.innerWidth, window.innerHeight]);
|
||
|
|
||
|
useEffect(() => {
|
||
|
const windowSizeHandler = () => {
|
||
|
setWindowSize([window.innerWidth, window.innerHeight]);
|
||
|
};
|
||
|
window.addEventListener("resize", windowSizeHandler);
|
||
|
return () => {
|
||
|
window.removeEventListener("resize", windowSizeHandler);
|
||
|
};
|
||
|
}, []);
|
||
|
|
||
|
return windowSize;
|
||
|
};
|
||
|
|
||
|
export default useSize;
|