From 2a6a501da55544d916626b72eb9d4c8bd24983fc Mon Sep 17 00:00:00 2001 From: Daniel Williams <dannyhyunsoowilliams@gmail.com> Date: Sat, 3 Feb 2024 20:49:55 +0000 Subject: [PATCH] fix: errors on react native when running compose story --- code/lib/preview-api/src/modules/preview-web/UrlStore.ts | 2 +- code/lib/preview-api/src/modules/preview-web/WebView.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts index 16d66ba7f6b6..f69e6b520f96 100644 --- a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts +++ b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts @@ -65,7 +65,7 @@ const getFirstString = (v: ValueOf<qs.ParsedQs>): string | void => { }; export const getSelectionSpecifierFromPath: () => SelectionSpecifier | null = () => { - const query = qs.parse(document.location.search, { ignoreQueryPrefix: true }); + const query = qs.parse(document?.location?.search, { ignoreQueryPrefix: true }); const args = typeof query.args === 'string' ? parseArgsParam(query.args) : undefined; const globals = typeof query.globals === 'string' ? parseArgsParam(query.globals) : undefined; diff --git a/code/lib/preview-api/src/modules/preview-web/WebView.ts b/code/lib/preview-api/src/modules/preview-web/WebView.ts index 6f02568934c3..eefa4f007856 100644 --- a/code/lib/preview-api/src/modules/preview-web/WebView.ts +++ b/code/lib/preview-api/src/modules/preview-web/WebView.ts @@ -47,7 +47,7 @@ export class WebView implements View<HTMLElement> { constructor() { // Special code for testing situations // eslint-disable-next-line @typescript-eslint/naming-convention - const { __SPECIAL_TEST_PARAMETER__ } = qs.parse(document.location.search, { + const { __SPECIAL_TEST_PARAMETER__ } = qs.parse(document?.location?.search, { ignoreQueryPrefix: true, }); switch (__SPECIAL_TEST_PARAMETER__) {