From 955887f78eb54d83e13683cf12a0cc259b3956e7 Mon Sep 17 00:00:00 2001 From: Sebastian Klingler Date: Mon, 3 Apr 2023 16:50:30 -0500 Subject: [PATCH] [C-2406] Null check localStorage (#3150) --- packages/web/src/store/storeContext.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web/src/store/storeContext.ts b/packages/web/src/store/storeContext.ts index c8020525f2a..9c09b022564 100644 --- a/packages/web/src/store/storeContext.ts +++ b/packages/web/src/store/storeContext.ts @@ -26,9 +26,10 @@ import { share } from 'utils/share' import { getLineupSelectorForRoute } from './lineup/lineupForRoute' export const storeContext: CommonStoreContext = { - getLocalStorageItem: async (key: string) => window.localStorage.getItem(key), + getLocalStorageItem: async (key: string) => + window?.localStorage?.getItem(key), setLocalStorageItem: async (key: string, value: string) => - window.localStorage.setItem(key, value), + window?.localStorage?.setItem(key, value), // Note: casting return type to Promise to maintain pairity with mobile, but // it may be best to update mobile to not be async getFeatureEnabled: getFeatureEnabled as unknown as (