From b64ed9fa4c5f323344941ad34e172905a0c86029 Mon Sep 17 00:00:00 2001 From: Rob Knight Date: Sun, 10 Nov 2024 09:43:40 +0700 Subject: [PATCH 1/2] Handle undefined orientation --- apps/passport-client/new-components/shared/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/passport-client/new-components/shared/utils.ts b/apps/passport-client/new-components/shared/utils.ts index 433edfd9f5..5f615eba78 100644 --- a/apps/passport-client/new-components/shared/utils.ts +++ b/apps/passport-client/new-components/shared/utils.ts @@ -1,11 +1,11 @@ import { serializeStorage } from "@pcd/passport-interface"; import { useCallback, useEffect, useState } from "react"; +import { css } from "styled-components"; import { usePCDCollection, useSelf, useSubscriptions } from "../../src/appHooks"; -import { css } from "styled-components"; export const useExport = (): (() => Promise) => { const user = useSelf(); @@ -40,7 +40,7 @@ export const isMobile = /Mobi|Android/i.test(navigator.userAgent); export const useOrientation = (): ScreenOrientation => { const [state, setState] = useState( - window.screen.orientation + window.screen.orientation ?? { type: "portrait-primary" } ); useEffect(() => { @@ -48,7 +48,7 @@ export const useOrientation = (): ScreenOrientation => { let mounted = true; const onChange = (): void => { - if (mounted) { + if (mounted && screen.orientation) { const { orientation } = screen; setState(orientation); From 56aaaf26a5a703836d2de7f6585c5eae68fb18ed Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Sun, 10 Nov 2024 00:41:55 -0800 Subject: [PATCH 2/2] Update apps/passport-client/new-components/shared/utils.ts --- apps/passport-client/new-components/shared/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/passport-client/new-components/shared/utils.ts b/apps/passport-client/new-components/shared/utils.ts index 5f615eba78..8628c593dd 100644 --- a/apps/passport-client/new-components/shared/utils.ts +++ b/apps/passport-client/new-components/shared/utils.ts @@ -40,7 +40,7 @@ export const isMobile = /Mobi|Android/i.test(navigator.userAgent); export const useOrientation = (): ScreenOrientation => { const [state, setState] = useState( - window.screen.orientation ?? { type: "portrait-primary" } + window.screen?.orientation ?? { type: "portrait-primary" } ); useEffect(() => {