diff options
| author | Yash <[email protected]> | 2024-04-04 08:33:24 +0000 |
|---|---|---|
| committer | Yash <[email protected]> | 2024-04-04 08:33:24 +0000 |
| commit | 5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95 (patch) | |
| tree | 1b7888278999b7e67d3ce11968d928bda4652b52 /apps | |
| parent | better focus states (diff) | |
| download | supermemory-5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95.tar.xz supermemory-5469c5d41a1e4d40b2aebde266dd7c4e2d2c8a95.zip | |
fix window undefined error
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/src/hooks/useViewport.ts | 23 |
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() { |