mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-12 05:51:45 +00:00
fix window undefined error
This commit is contained in:
parent
216c55ff32
commit
5469c5d41a
1 changed files with 15 additions and 8 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue