-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Global decorators don't work in storyshots when applied in config file #877
Comments
+1 |
I tried to reproduce this and failed: https://github.com/tmeasday/storybook/tree/issue-877 Here's what I did:
@chrbala / @wuzhuzhu maybe you can fork my branch above and tweak it to reproduce the problem? |
@tmeasday I've got a similar issue using Styletron. import React from 'react';
import {addDecorator} from '@storybook/react';
import Styletron from 'styletron-client';
import {StyletronProvider} from 'styletron-react';
const styletron = new Styletron();
addDecorator(story => (
<StyletronProvider styletron={styletron}>{story()}</StyletronProvider>
)); Everything works fine at first load. But when I change something with HMR it looses context on update and I get |
Hi @faddee -- this sounds like maybe a different issue (this particular problem has to do with storyshots, so HMR wouldn't have been involved). Can you maybe open a new issue and if you are able to a reproduction of the bug with Styletron would be amazing! |
@tmeasday Oh, missed the snapshot part. Thanks for clearing that up. |
I've added an example to #879 |
This change breaks HMR for me. I never had a problem with decorators in the past. Anyone have some tips on how to change my config? I just add decorators then load the stories, which is how the docs say to do things... addDecorator(marketStatusDecorator)
function loadStories() {
const req = require.context('../js', true, /\.stories\.js$/)
req.keys().forEach((filename) => req(filename))
}
configure(loadStories, module) |
I am implementing a decorator exactly as @ntucker describes and using Storyshots. I have one test that sets's up Storyshot, and it looks like this:
import initStoryshots from '@storybook/addon-storyshots'
initStoryshots() That's it. The rest of my config is all contained in import { configure, addDecorator } from '@storybook/react'
import Decorator from './decorator'
const req = require.context('../src/components', true, /story.js$/)
addDecorator(Decorator)
const loadStories = () => {
require('./Welcome/story')
req.keys().forEach(filename => req(filename))
}
configure(loadStories, module) I get the error: |
Looks like we need to reopen it or create a new one issue? |
Issue by chrbala
Thursday Dec 01, 2016 at 07:09 GMT
Originally opened as storybook-eol/storyshots#59
I am using addDecorator for a few context-providing components. It works when I apply them via storiesOf(...).addDecorator, or globally in a story.
However, global decorators seem to be ignored entirely when applied in the config file.
I am using storybook@2.33.1 and storyshots@2.1.0.
The text was updated successfully, but these errors were encountered: