From fba3a84923d31eb56384e3be6596e87c67d7b51d Mon Sep 17 00:00:00 2001 From: Aruna Herath Date: Thu, 22 Sep 2016 14:57:02 +0530 Subject: [PATCH] Check if we are on storyshots in preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit storyshots adds polyfills for window. So preview will incorrectly assume we’re on a browser. This will avoid that. --- src/client/preview/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/preview/index.js b/src/client/preview/index.js index 994c8d857e3..6785eee76e7 100644 --- a/src/client/preview/index.js +++ b/src/client/preview/index.js @@ -12,8 +12,13 @@ import init from './init'; import { selectStory } from './actions'; import reducer from './reducer'; +// check if we're on storyshots +const { navigator } = global; +const isStoryShots = navigator && navigator.userAgent === 'storyshots'; + // check whether we're running on node/browser -const isBrowser = typeof window !== 'undefined'; +// storyshots got polyfills for window so need to make sure its not storyshots +const isBrowser = typeof window !== 'undefined' && !isStoryShots; const storyStore = new StoryStore(); const reduxStore = createStore(reducer);