aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYash <[email protected]>2024-04-04 08:33:24 +0000
committerYash <[email protected]>2024-04-04 08:33:24 +0000
commit5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95 (patch)
tree1b7888278999b7e67d3ce11968d928bda4652b52
parentbetter focus states (diff)
downloadsupermemory-5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95.tar.xz
supermemory-5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95.zip
fix window undefined error
-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() {