Skip to content

Commit

Permalink
fix: remaining window access
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed May 26, 2023
1 parent 93bf803 commit fbb6060
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 12 additions & 8 deletions src/components/masa-interface/pages/gallery/index.tsx
Expand Up @@ -98,14 +98,18 @@ const GalleryContainer = () => {
const pages = [Gallery];
const { useModalSize, fullScreenGallery } = useMasa();

useModalSize?.(
fullScreenGallery
? {
width: window.innerWidth * 0.95,
height: window.innerHeight * 0.95,
}
: { width: 1100, height: 800 }
);
if (typeof window !== 'undefined') {
useModalSize?.(
fullScreenGallery
? {
width: window.innerWidth * 0.95,
height: window.innerHeight * 0.95,
}
: { width: 1100, height: 800 }
);
} else {
useModalSize?.({ width: 1100, height: 800 });
}

const { sbts } = useTabs();

Expand Down
8 changes: 6 additions & 2 deletions src/components/modal/modal.tsx
Expand Up @@ -21,8 +21,12 @@ export default function useWindowDimensions() {
setWindowDimensions(getWindowDimensions());
}

window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
if (typeof window !== 'undefined')
window.addEventListener('resize', handleResize);
return () => {
if (typeof window !== 'undefined')
window.removeEventListener('resize', handleResize);
};
}, []);

return windowDimensions;
Expand Down

0 comments on commit fbb6060

Please sign in to comment.