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

Hot reloading breaks with React Native when having multiple storiesOf in a single file #3703

Closed
koenpunt opened this issue Jun 4, 2018 · 9 comments

Comments

@koenpunt
Copy link
Contributor

koenpunt commented Jun 4, 2018

Bug or support request summary

Hot reloading breaks with React Native when having multiple storiesOf in a single file.

After reading through previous issues concerning the "Story of "XXX" named "XXX" already exists" error, I found the following comment

The issue can be easily reproduced when storiesOf is called two or more times in a single js file (like in the auto-generated stories). Both calls try to set a dispose callback, but the metro "require" polyfill retains only the last one. Any modifications to that file will lead to the error.

#3348 (comment).

After testing this, it indeed does work when there's only a single storiesOf(.., ..) in a file, but when adding another it breaks.

Steps to reproduce

Have a React Native project with Storybooks set up, and add a new story file containing 2 storiesOf() with different naming, for example:

storiesOf('Tutorial/Steps', module)
  .add('Default', () => {
    return <Steps />;
  });

storiesOf('Tutorial/Steps/Congratulations', module)
  .add('Active', () => {
    return <StepCongratulations />;
  });

Make sure that you have hot reloading enabled, and when editing and saving the story file, the app with give the "Story of "XXX" named "XXX" already exists" error.

Possible solution

What I think could work is if an intermediate method for the dispose method is added, that keeps track of all the callbacks registered, as opposed to Metro bundlers require polyfill, that only retains the last callback.

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/react-native 3.4.6
  • @storybook/addon-actions 3.4.6
  • @storybook/addon-links 3.4.6

Affected platforms

React Native 0.55.3

@stale
Copy link

stale bot commented Jul 2, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jul 2, 2018
@vicentedealencar
Copy link

I had the same issue

@stale stale bot removed the inactive label Jul 6, 2018
@stale
Copy link

stale bot commented Jul 27, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jul 27, 2018
@GrafMine
Copy link

I had the same issue

@stale stale bot removed the inactive label Aug 11, 2018
@stale
Copy link

stale bot commented Sep 1, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Sep 1, 2018
@sregg
Copy link

sregg commented Sep 5, 2018

I'm having the same issue, is there any fix?

@stale stale bot removed the inactive label Sep 5, 2018
@igor-dv
Copy link
Member

igor-dv commented Sep 10, 2018

@michaelduminy, does your PR fix this ?

@mikeduminy
Copy link
Contributor

@igor-dv I think so. I never noticed it affect multiple storiesOf calls more than single calls, but the symptom is the same so my guess is the PR fixes this.

@igor-dv igor-dv added the merged label Sep 10, 2018
@stale
Copy link

stale bot commented Oct 1, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

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

7 participants