Skip to content

Commit 5f62a42

Browse files
committed
Guard window usage in useMedia to prevent errors in non-browser environments.
1 parent 715c391 commit 5f62a42

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/MediaConsumer/useMedia.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const useMedia = (sizes?: NoXsMediaSize[]) => {
1313
const breakpoints = theme[themeName]?.gridBreakpoints;
1414

1515
const getResize = () => {
16-
const width = window.innerWidth;
16+
const width = typeof window !== 'undefined' ? window.innerWidth: 0;
1717
let size: TMediaSize = 'xs';
1818

1919
if ((!sizes || sizes?.includes('xxl')) && width >= breakpoints.xxl) {

0 commit comments

Comments
 (0)