Passing props into stories through decorators no longer working in Storybook 6.3
See original GitHub issueDescribe the bug Prior to version 6.3 of Storybook, when I create a decorator, I’m able to pass props into it like so
export const withFoobar = (Story, context) => (
<Story foobar="foo" {...context} />
);
And then I expect to be able to access the props from any story:
const Template = (args, { foobar }) => {
return (
<div>
<Button {...args} />
<p>
This value should say 'foo': <code>{foobar}</code>
</p>
</div>
);
};
However, as of 6.3, the props I pass in via the decorator are now undefined
.
To Reproduce
https://github.com/JoshTumath/storybook-decorator-props-bug-repro
System
Environment Info:
System:
OS: macOS 11.4
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
Yarn: 2.4.2 - /usr/local/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
Browsers:
Chrome: 91.0.4472.114
Safari: 14.1.1
npmPackages:
@storybook/addon-actions: ^6.4.0-alpha.4 => 6.4.0-alpha.4
@storybook/addon-docs: ^6.4.0-alpha.4 => 6.4.0-alpha.4
@storybook/addon-essentials: ^6.4.0-alpha.4 => 6.4.0-alpha.4
@storybook/addon-links: ^6.4.0-alpha.4 => 6.4.0-alpha.4
@storybook/react: ^6.4.0-alpha.4 => 6.4.0-alpha.4
Additional context None
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Decorators - Storybook - JS.ORG
A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators to augment your stories with extra...
Read more >Storybook 6 decorator pass props to story not working
I want to have the option to pass state to my stories using state and setState props. This is how I defined my...
Read more >@storybook/addon-knobs - npm
Storybook Addon Knobs allow you to edit props dynamically using the ... Add the `withKnobs` decorator to add knobs support to your stories....
Read more >Story for a Component With Content Projection - Medium
Storybook and Angular components. Context: Angular 12, StoryBook 6.3.9. Hey, I started to use Storybook and I would Like to share my experience....
Read more >Storybook Unable to load on DSM website - InVision Support
First the template.Bind() it's not valid anymore with Storybook version 6.3.6, then I had to make a lot of changes inside story.js, preview.js ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@JoshTumath Yes, will release in 6.3.x later this week or first thing next
Thanks @JoshTumath. I can confirm this is a regression from
6.2.9
which was introduced in6.3.0-alpha.15
, presumably in this PR: https://github.com/storybookjs/storybook/pull/14692