hey guys im using a map api and it only allows me to set the map width in js. So in order to make it responsive i wrote this code but i dont know why its not working…
function useWindowSize() {
const [size, setSize] = useState([0]);
let phone = "320";
let tablet = "900";
let bigScreen = "2600";
let bigLaptop = "1400";
let laptop = "1000";
useLayoutEffect(() => {
function updateSize() {
setSize([window.innerWidth]);
}
window.addEventListener("resize", updateSize);
updateSize();
return () => window.removeEventListener("resize", updateSize);
}, []);
if (size > bigLaptop && size < bigScreen) {
return "80vw";
} else if (size > laptop && size < bigLaptop) {
return "67vw";
} else if (size < tablet) {
return "40vw";
}
}
//For map API location Bali
export function Map() {
const [mediaWidth] = useWindowSize();
const [viewport, setViewport] = useState({
latitude: -8.340539,
longitude: 115.091949,
width: { mediaWidth },
height: "100vh",
zoom: 10,
});