ArgsTable: Add warning when subcomponents is an array

This commit is contained in:
Michael Shilman 2020-08-15 02:06:00 +08:00
parent 210bd62343
commit 4b5f29b3fc
2 changed files with 15 additions and 0 deletions

View File

@ -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} />;

View File

@ -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>;