From 4f5eaa27f01f0dfc3a49cc084557116e6766a683 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 10 Jun 2020 09:46:40 -0700 Subject: [PATCH] fix: Return null if the SDK is not available --- src/hooks/useApiDoc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hooks/useApiDoc.js b/src/hooks/useApiDoc.js index c0fc66dbb..eeb5e8d5d 100644 --- a/src/hooks/useApiDoc.js +++ b/src/hooks/useApiDoc.js @@ -18,6 +18,10 @@ const useApiDoc = (name) => { if (typeof window === 'undefined') global.window = {}; return useMemo(() => { + if (window.__NR1_SDK__ == null) { + return null; + } + const sdk = window.__NR1_SDK__?.default ?? {}; const api = sdk[name]; @@ -59,7 +63,7 @@ const useApiDoc = (name) => { }; }), }; - }, [name, window?.__NR1_SDK__]); + }, [name, window.__NR1_SDK__]); }; export default useApiDoc;