Storybook: Question: what is "module" the second argument of storiesOf?

Created on 12 Oct 2017  路  5Comments  路  Source: storybookjs/storybook

For this code, what is module? and what can you do with it?

storiesOf('Button', module)
  .add('with text', () => (
    <Button onClick={action('clicked')}>Hello Button</Button>
  ))
question / support

Most helpful comment

that's indeed it @elisechant !

Storybook needs a reference to the file/module where your story-code is int to enable hpt-module-replacement.

If you do not supply it, you'd need to refresh your browser for every change you make to your component & story code.

I hope this helps!
(please re-open if your have further questions)

All 5 comments

A colleague at my workplace has suggested that module relates to the ES5 export syntax module.exports.

that's indeed it @elisechant !

Storybook needs a reference to the file/module where your story-code is int to enable hpt-module-replacement.

If you do not supply it, you'd need to refresh your browser for every change you make to your component & story code.

I hope this helps!
(please re-open if your have further questions)

How we overcome the ESLint error that 'module' is not defined?

https://eslint.org/docs/user-guide/configuring#specifying-environments

You tell eslint that the code will run in node and it should recognised that module exists.

alternatively this is a solution too:
https://stackoverflow.com/questions/39053562/eslint-no-undef-and-webpack-plugin

thanks @ndelangen

adding following to my eslintrc file worked for me

"env": {
    "browser": true,
    "node": true
  }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dependencies[bot] picture dependencies[bot]  路  142Comments

ilyaulyanov picture ilyaulyanov  路  100Comments

tycho01 picture tycho01  路  76Comments

bpeab picture bpeab  路  70Comments

joeruello picture joeruello  路  79Comments