How to assign size to AccordionHeader in Storybook #26066
-
Hello, I am getting this warning when I try to assign a size to AccordionHeader in Storybook.
This is the short version of my code: const Template: ComponentStory<typeof Accordion> = (
args: AccordionHeaderProps
) => (
<Accordion>
<AccordionItem value="1">
<AccordionHeader {...args}>Accordion Header 1</AccordionHeader>
<AccordionPanel>
<div>Accordion Panel 1</div>
</AccordionPanel>
</AccordionItem>
</Accordion>
);
export const Sizes = Template.bind({});
Sizes.args = { size: "small" }; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Since the If you do this, it fixes the error: const Template: ComponentStory<typeof AccordionHeader> = (
args: AccordionHeaderProps
) => (
<Accordion>
<AccordionItem value="1">
<AccordionHeader {...args}>Accordion Header 1</AccordionHeader>
<AccordionPanel>
<div>Accordion Panel 1</div>
</AccordionPanel>
</AccordionItem>
</Accordion>
);
export const Sizes = Template.bind({});
Sizes.args = { size: "small" }; |
Beta Was this translation helpful? Give feedback.
Since the
Template
is typed asComponentStory<typeof Accordion>
,Sizes.args
is typed asAccordionProps
, notAccordionHeaderProps
. The type of the function parameter (args
) isn't affecting that type inference.If you do this, it fixes the error: