Skip to content

Commit

Permalink
Merge pull request #12033 from storybookjs/fix/argstable-subcomponent…
Browse files Browse the repository at this point in the history
…s-warning

ArgsTable: Error when subcomponents is an array
  • Loading branch information
shilman committed Aug 14, 2020
2 parents 210bd62 + 4b5f29b commit 2786fb3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/docs/src/blocks/ArgsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export const StoryTable: FC<
}

if (subcomponents) {
if (Array.isArray(subcomponents)) {
throw new Error(
`Unexpected subcomponents array. Expected an object whose keys are tab labels and whose values are components.`
);
}
tabs = addComponentTabs(tabs, subcomponents, context, include, exclude);
}
return <TabbedArgsTable tabs={tabs} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import Button from '../../components/TsButton';

export default {
title: 'Addons/Docs/Subcomponents array',
component: Button,
subcomponents: [Button],
};

export const Basic = () => <Button>Bad subcomponents</Button>;

0 comments on commit 2786fb3

Please sign in to comment.