import React, { useEffect } from "react";
import { useState } from "react";

const useWindowSize = () => {
  const [size, setSize] = useState([0, 0]);
  const [width, setWidth] = useState(0);
  const [height, setHeight] = useState(0);
  useEffect(() => {
    const updateSize = () => {
      setWidth(window.innerWidth);
      setHeight(window.innerHeight);
    };
    window.addEventListener("resize", updateSize);
    updateSize();
    return () => window.removeEventListener("resize", updateSize);
  }, []);
  return { width: width, height: height };
};

export { useWindowSize };
