storybook: .addDecorator is probably not working

Issue by kitze Friday Dec 23, 2016 at 23:37 GMT _Originally opened as https://github.com/storybooks/storyshots/issues/68_


I’m using material-ui in my project for some of the components. The components that are not affected by material-ui and don’t need muiTheme pass the tests. But the other components that need muiTheme provided by context, are failing with a warning Warning: Failed context type: The context `muiTheme` is marked as required in `CircularProgress`, but its value is `undefined`.

Keep in mind that the stories in storybook are fine because I’m providing muiTheme through a decorator like this in my global .storybook/config.js file:

addDecorator(story => wrapWithStyles(story()));
addDecorator(story => wrapWithMui(story()));

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 19 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I can fix the repro @ktj provided with the following diff:

image

This ensures that addDecorator is called before the stories are loaded.

I’m guessing just moving the addDecorator line above the require.context line should work too, no?

This seems like a documentation problem more than anything. Perhaps the global addDecorator should log a warning if a story has already been registered, as this is unlikely to be what you want?

@tmeasday Sure, I’ll try to send one in the next couple days.

I’ll mark it merged and we’ll close it when it gets released (soon!)