question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addDecorator doesn't work on config.js

See original GitHub issue

Describe the bug I am trying to implement some global style. And I think config.js is the good place to put my code. I copied the addDecorator from the official storybook doc to test. But it shows the error:

in ./.storybook/config.js
Module build failed (from ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/ccl/dev/storybook-sandbox/.storybook/config.js: Unexpected token (3:35)

 1 | import { configure, addDecorator } from '@storybook/react';
 2 | 
> 3 | const CenterDecorator = storyFn => <div style={styles}>{storyFn()}</div>;
   |                                    ^
 4 | addDecorator(CenterDecorator);

I am using the create-react-app and @storybook/react": "^5.1.3 It is a problem with Create-react-app?

The addDecorator works fine on individual components but it does not work on config.js

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:27 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
shilmancommented, Jul 17, 2019

Good news, I think @mrmckeb is going to fix this!

2reactions
shilmancommented, Sep 3, 2019

@justinlazaro-iselect Does creating .storybook/babel.config.js with the following content work?

module.exports = {
  presets: [
    "@babel/preset-env",
    "@babel/preset-react"
  ]
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook addDecorator does not work from config.js?
When I was trying to make storybook work with typescript I had to upgrade this package from 3.4.8 version to 4.0.0-alpha.10. Here are...
Read more >
storybook-addon-i18n
Create a file called addons.js in your Storybook config, if there is no any and append following line: · Then in your story's...
Read more >
storybook-addon-react-docgen - npm
There exist other addons that do this, but they didn't work in the ... Create or add to a file called addons.js in...
Read more >
Workaround for using non-declarative configuration in the ...
js , move them to config.js . // preview.js import { addDecorator } from '@storybook/svelte'; import { withA11y } from '@storybook/addon-a11y ...
Read more >
Storybook Docs with mdx support and addon knobs - Medium
);addDecorator(storyWrapper);configure(loadStories, module);. Okay, not bad, everything seems to be working after that. Docs addon. Next, I try ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found