Skip to content

Commit

Permalink
Fix: Docs fail to render when using generated stories
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jakubriedl authored Mar 12, 2021
1 parent 49c5e5b commit 10ad73a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/docs/src/blocks/enhanceSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 10ad73a

Please sign in to comment.