fix window undefined error

This commit is contained in:
Yash 2024-04-04 08:33:24 +00:00
parent 216c55ff32
commit 5469c5d41a

View file

@ -1,14 +1,21 @@
import { useState, useEffect } from "react";
function getViewport() {
const { innerWidth: width, innerHeight: height } = window ?? {
innerWidth: 0,
innerHeight: 0,
};
return {
width,
height,
};
try {
const { innerWidth: width, innerHeight: height } = window ?? {
innerWidth: 0,
innerHeight: 0,
};
return {
width,
height,
};
} catch {
return {
width: 0,
height: 0,
};
}
}
export default function useViewport() {