This is my .storybook/confg.js
import { addDecorator, configure } from '@storybook/react';
import { IntlProvider } from 'react-intl';
// ...
addDecorator(story => (
<IntlProvider locale={DEFAULT_LOCALE} key={DEFAULT_LOCALE} messages={DEFAULT_MESSAGES}>
{ story() }
</IntlProvider>
));
// ... loadStories, etc
configure(loadStories, module);
After each change in components code, hot reloading module reload iframe in the storybook and I get an error instead of component:
[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.
Invariant Violation: [React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.
at invariant (http://localhost:6006/static/preview.bundle.js:23458:15)
at invariantIntlContext (http://localhost:6006/static/preview.bundle.js:72412:54)
at new InjectIntl (http://localhost:6006/static/preview.bundle.js:72485:13)
at http://localhost:6006/static/preview.bundle.js:56978:18
at measureLifeCyclePerf (http://localhost:6006/static/preview.bundle.js:56758:12)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (http://localhost:6006/static/preview.bundle.js:56977:16)
at ReactCompositeComponentWrapper._constructComponent (http://localhost:6006/static/preview.bundle.js:56963:21)
at ReactCompositeComponentWrapper.mountComponent (http://localhost:6006/static/preview.bundle.js:56871:21)
at Object.mountComponent (http://localhost:6006/static/preview.bundle.js:63530:35)
at ReactDOMComponent.mountChildren (http://localhost:6006/static/preview.bundle.js:62882:44)
But after reloading the whole page, all works normally.
@Kein1945 It's a known issue with global decorators
As a workaround put your decorator inside configure:
function loadStories() {
addDecorator(story => (
<IntlProvider locale={DEFAULT_LOCALE} key={DEFAULT_LOCALE} messages=
{DEFAULT_MESSAGES}>
{ story() }
</IntlProvider>
));
}
configure(loadStories, module);
That works for me. Thank you for your quick reply!
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Most helpful comment
@Kein1945 It's a known issue with global decorators
As a workaround put your decorator inside
configure: