Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Error handling for invalid Story id #7965

Merged
merged 13 commits into from
Sep 4, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import DocgenButton from '../../components/DocgenButton';

<Props of="." />

<Preview>
<Story id="empty-story" />
shilman marked this conversation as resolved.
Show resolved Hide resolved
</Preview>

## A random color ColorPalette

<ColorPalette>
Expand Down
5 changes: 4 additions & 1 deletion lib/components/src/blocks/Story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ const IFrameStory: React.FunctionComponent<IFrameStoryProps> = ({
const Story: React.FunctionComponent<StoryProps> = props => {
const { error } = props as ErrorProps;
const { storyFn } = props as InlineStoryProps;
const { id, inline, title, height } = props;
const { id, inline, title, height, children } = props;

if (error) {
return <EmptyBlock>{error}</EmptyBlock>;
}
if (!children) {
atanasster marked this conversation as resolved.
Show resolved Hide resolved
return <EmptyBlock>{StoryError.NO_STORY}</EmptyBlock>;
}
return inline ? (
<InlineStory id={id} storyFn={storyFn} title={title} height={height} />
) : (
Expand Down