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

Add story funtion breaks HMR #7148

Closed
Jony-Y opened this issue Jun 19, 2019 · 3 comments
Closed

Add story funtion breaks HMR #7148

Jony-Y opened this issue Jun 19, 2019 · 3 comments

Comments

@Jony-Y
Copy link

Jony-Y commented Jun 19, 2019

Hi,
I'm trying to create my own wrapper to create stories, to save some redundant code.
every time I use my createStory, the story loads fine but the HMR breaks and I get this warning in the console

I tested everything, even dumbed down versions, still doesnt work

lets say I have a function:

/** createStory*/ export default (section) => storiesOf(section, module)

and I try to use it in my story file

/** component.story.js */ createStory('my Story').add(...)

This will not get HMR, and I will get this error:

story with id v2-components--avatar-structures already exists in the store!
Perhaps you added the same story twice, or you have a name collision?
Story ids need to be unique -- ensure you aren't using the same names modolo url-sanitization.

now if I do this:
/** component.story.js */ storiesOf('My Story', module).add(...)

everything works fine.

can someone help?

using:
@storybook: 5.1.8
react: 16.8.6

@shilman
Copy link
Member

shilman commented Jun 19, 2019

AFAIK you need module to be different for each storiesOf call, so you should pass it individually each time.

In 5.2 we'll be releasing a new story format where you can just export functions and just export stories as functions: #7110

@shilman shilman added this to the 5.1.x milestone Jun 19, 2019
@Jony-Y
Copy link
Author

Jony-Y commented Jun 20, 2019

so if I pass the module? would that work?

@Jony-Y
Copy link
Author

Jony-Y commented Jun 20, 2019

So, Adding module to the createStory function worked. Thanks!

@Jony-Y Jony-Y closed this as completed Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants