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

Storybook crashes when using Addon Knobs (evaluating this.props.channel.on) #1586

Closed
DaniyarJakupov opened this issue Aug 3, 2017 · 10 comments

Comments

@DaniyarJakupov
Copy link

DaniyarJakupov commented Aug 3, 2017

Version
App bootstrapped with create-react-native-app.

"react-native": "0.46.1",
"@storybook/addon-knobs": "^3.2.0",
"@storybook/react-native": "3.2.3",

Reproduction
When I add withKnobs decorator to the story, storybook crashes with this error:

screen shot 2017-08-03 at 17 04 20

screen shot 2017-08-03 at 17 09 36

As soon as I remove .addDecorator(withKnobs) everything is working fine
Index.js

import React from 'react';
import { Text } from 'react-native';

import { storiesOf } from '@storybook/react-native';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import { withKnobs, text, boolean, number, select } from '@storybook/addon-knobs';

import Button from './Button';
import CenterView from './CenterView';
import Welcome from './Welcome';
import Label from './Label';

storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Label', module)
  .addDecorator(getStory =>
    <CenterView>
      {getStory()}
    </CenterView>
  )
  .addDecorator(withKnobs)
  .add('vertical', () =>
    <Label
      onPress={action('clicked-text')}
      title={text('Title', 'Place')}
      population={number('Population', 8)}
      secondary={boolean('Secondary', false)}
    />
  );

@rkichenama
Copy link

I am not sure why, but when I npm i -D react-inspector everything got fixed.

@Gongreg
Copy link
Member

Gongreg commented Aug 10, 2017

@DaniyarJakupov, I found the issue, I am working on pr to fix it. I should be able to fix it today.

@kwelch
Copy link

kwelch commented Aug 11, 2017

Same for me, but installing react-inspector has not fixed the issue.

@DaniyarJakupov
Copy link
Author

Just downgrade to "3.1.9" version. That should do the trick. At least it worked for me

@Gongreg
Copy link
Member

Gongreg commented Aug 13, 2017

@DaniyarJakupov, @kwelch the pr is still not merged. So yes, for now switch to older version. I'll notify you when pr is merged.

@aloifolia
Copy link

aloifolia commented Oct 5, 2017

I ran into a similar issue with Storybook and React Native:
image

const stories = storiesOf('XY', module)
  .add('crash', () => {
    const foo = Knobs.text('42');
    return <Text>{foo}</Text>;
  });
  
stories.addDecorator(Knobs.withKnobs);

Which version would you recommend to use? I tried 3.1.9 but ran into further issues...

@Gongreg
Copy link
Member

Gongreg commented Oct 7, 2017

@aloifolia, hey, did you try adding decorator before stories? It looks like knobs are trying to emit events even though the decorator is not created yet.

@masm
Copy link

masm commented Oct 31, 2017

This is still an issue for me with version 3.2.13

@stale
Copy link

stale bot commented Dec 23, 2017

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 60 days. Thanks!

@stale stale bot added the inactive label Dec 23, 2017
@stale
Copy link

stale bot commented Jan 7, 2018

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

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