From ffed14cb5cd22d757c290ea2219e322f62e31d7d Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 8 Jul 2020 00:01:35 -0700 Subject: [PATCH] fix: dont use window for component scope --- src/components/ReferenceExample.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/ReferenceExample.js b/src/components/ReferenceExample.js index 6858df4b9..40d573f76 100644 --- a/src/components/ReferenceExample.js +++ b/src/components/ReferenceExample.js @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react'; +import React, { useCallback, useMemo } from 'react'; import PropTypes from 'prop-types'; import styles from './ReferenceExample.module.scss'; import ReferencePreview from './ReferencePreview'; @@ -16,13 +16,6 @@ const nerdletStateContextMock = { entityGuid: 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx', }; -const SCOPE = { - ...window.__NR1_SDK__.default, - navigation: { - getOpenLauncherLocation: () => {}, - }, -}; - const ReferenceExample = ({ className, example, @@ -35,6 +28,16 @@ const ReferenceExample = ({ } = window.__NR1_SDK__.default; const { live } = example.options; + const scope = useMemo( + () => ({ + ...window.__NR1_SDK__.default, + navigation: { + getOpenLauncherLocation: () => {}, + }, + }), + [] + ); + const Preview = useCallback( ({ className }) => ( {example.sourceCode}