From eca0918cf427b18230626e9827577909b9e01384 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 9 May 2022 17:14:10 +1000 Subject: [PATCH] Cleanup --- addons/docs/src/blocks/ExternalPreview.ts | 2 -- addons/docs/src/blocks/Story.tsx | 20 +++++++------------- lib/preview-web/src/DocsRender.ts | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/addons/docs/src/blocks/ExternalPreview.ts b/addons/docs/src/blocks/ExternalPreview.ts index 99879f4b655..cd365a89e9e 100644 --- a/addons/docs/src/blocks/ExternalPreview.ts +++ b/addons/docs/src/blocks/ExternalPreview.ts @@ -82,9 +82,7 @@ export class ExternalPreview extends Preview = (props) => { const story = useStory(storyId, context); const [showLoader, setShowLoader] = useState(true); - // FIXME: do we need this? - // Register the story with the context, which is needed by external rendering - // context.addStory(of, false); - useEffect(() => { let cleanup: () => void; - if (storyRef.current) { + if (story && storyRef.current) { const element = storyRef.current as HTMLElement; - if (story) { - cleanup = context.renderStoryToElement(story, element); - setShowLoader(false); - } + cleanup = context.renderStoryToElement(story, element); + setShowLoader(false); } return () => cleanup && cleanup(); }, [story]); @@ -171,15 +165,15 @@ const Story: FunctionComponent = (props) => { // FIXME: height/style/etc. lifted from PureStory const { height } = storyProps; return ( -
+
{height ? ( - + ) : null} {showLoader && }
@@ -202,7 +196,7 @@ const Story: FunctionComponent = (props) => { } return ( -
+
diff --git a/lib/preview-web/src/DocsRender.ts b/lib/preview-web/src/DocsRender.ts index 22d817590e9..02d933c8f1c 100644 --- a/lib/preview-web/src/DocsRender.ts +++ b/lib/preview-web/src/DocsRender.ts @@ -81,7 +81,7 @@ export class DocsRender implements Render), - // These three are intended for external renders only + // These is intended for the external docs render only setMeta: () => {}, };