aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/web/src/hooks/useViewport.ts23
1 files changed, 15 insertions, 8 deletions
diff --git a/apps/web/src/hooks/useViewport.ts b/apps/web/src/hooks/useViewport.ts
index f24ed2d2..7ba90861 100644
--- a/apps/web/src/hooks/useViewport.ts
+++ b/apps/web/src/hooks/useViewport.ts
@@ -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() {