-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 in config.js are removed after hot module reload #1637
Comments
There are two other reports of this in the original issue whose PR merge created this bug: #877 (comment) |
Any updates? |
@clementoriol it would be super useful for anyone picking up this issue if there's a ready to go reproduction repo to clone. So it would help out tremendously if you could set that up? 🙇 Switching from 3.2 to 3.1 solved the issue for you? damn, so we introduced this bug recently. Sorry about that. |
@ndelangen FYI the bug is added here: 8a48f80 |
We're having the same issue with applying a global decorator which disappears after hmr: // Custom decorator providing IntlProvider
const CustomIntlProvider = (storyFn) => (
<IntlProvider locale="en">
{ storyFn() }
</IntlProvider>
);
addDecorator(CustomIntlProvider); (We know there's storybook-addon-intl however it seems to introduce much more errors in our storybook so we decided to provide react-intl manually) Yet, adding the same decorator manually inside a story works just fine and does not break on hmr. import { IntlProvider } from 'react-intl';
import { storiesOf } from '@storybook/react';
import Component from '../component';
const CustomIntlProvider = (storyFn) => (
<IntlProvider locale="en">
{ storyFn() }
</IntlProvider>
);
storiesOf('Component', module)
.addDecorator(CustomIntlProvider)
.add('Component', () => <Component />); /cc @diablourbano |
@ndelangen I don't know why this 8a48f80 was added. All it does is break HMR. HMR will run modules again while maintaining state so it just throws and exception. PR is to revert this buggy commit. |
I think we are facing the same issue. I'll try to look into it ASAP. |
Thank you @igor-dv 🙇 |
Let's make some order.
IMO we need to revert this change and fix the storyshots problem in a proper way. |
The idea of #1481 was to help people who put their global decorators after their story modules are required, like: https://github.com/ktj/storybook-rp/blob/master/.storybook/config.js#L6-L20 Looking at it closer, the reason the above code breaks in SS is that storyshots does this totally zany thing to emulate Honestly, I think it's just mis-implemented, maybe there is something I am missing. We should revert the PR and fix the require context thing. |
Maybe it's far from being discussed (and a wrong place), but what if |
Still an issue :( |
Why is this closed? |
@wintercounter are you still seeing this? If so, what version? |
Latest. I'm having a custom ApolloProvider as: addDecorator(storyFn => <ApolloProvider client={client}>{storyFn()}</ApolloProvider>) |
@wintercounter |
Yes, it |
We still have this issue btw on 5.2.6. SInce we develop in Storybook in the first place, it makes the process really painful. |
@wintercounter Do you require your decorators from another file? I had this problem until I removed |
No, i have it in my setup: // Storybook setup file
import { addDecorator } from '@storybook/react'
import { ApolloProvider } from 'react-apollo'
import { ApolloClient } from 'apollo-client'
import { ApolloLink } from 'apollo-link'
import { InMemoryCache } from 'apollo-cache-inmemory'
const cache = new InMemoryCache()
const client = new ApolloClient({
link,
cache
})
addDecorator(storyFn => <ApolloProvider client={client}>{storyFn()}</ApolloProvider>) |
@wintercounter do you have a repro repo I can look at? |
@raphaelboukara global decorators should be applied in |
|
@peterp it is now |
Using the following package versions :
After adding global decorators in the config.js (before the configure function), the decorators work as expected (addon-info is here, addon-knobs works, etc.), but as soon as I save one of my file (a story for exemple), Storybook hot-reloads and the decorators are gone. Knobs doesn't work anymore, my custom decorator for wrapping the Preview component are gone, etc.
I tried removing decorators one by one with no success. The issues looks fairly consistent on any kind of Decorator.
I manage to find a workaround for now, downgrading my packages to these versions :
And it now works as expected.
I can't provide a simple repo reproducing the error right now, but I believe it must be easily reproducible (I encountered the same bug on two projets with very different configurations).
Let me now if you can't reproduce it, and I'll make one.
Thank you !
The text was updated successfully, but these errors were encountered: