From 10ad73ad03cda4489f51aa2046091e0da2276136 Mon Sep 17 00:00:00 2001 From: Jakub Riedl Date: Fri, 12 Mar 2021 17:52:37 +1100 Subject: [PATCH] Fix: Docs fail to render when using generated stories Docs page throw an error `Cannot read property 'startBody' of undefined` when using generated stories because it cannot get its source code. The fix is using the same simple fallback to the whole story file same as when locationsMap is not passed from caller. --- addons/docs/src/blocks/enhanceSource.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/docs/src/blocks/enhanceSource.ts b/addons/docs/src/blocks/enhanceSource.ts index e336c63c6503..9092bac11b05 100644 --- a/addons/docs/src/blocks/enhanceSource.ts +++ b/addons/docs/src/blocks/enhanceSource.ts @@ -20,6 +20,9 @@ const extract = (targetId: string, { source, locationsMap }: StorySource) => { const sanitizedStoryName = storyIdToSanitizedStoryName(targetId); const location = locationsMap[sanitizedStoryName]; + if (!location) { + return source; + } const lines = source.split('\n'); return extractSource(location, lines);