Global addDecorator not loaded
See original GitHub issueI see you already trying to solve this issue here #879 but I experiencing maybe the same. I haven’t digged into deeply but following code making issue.
import withThemes from './decorators/withThemes';
...
const spread = require.context('../app', true, /stories.jsx?$/);
...
addDecorator(withThemes);
...
function loadStories() {
spread.keys().forEach(filename => spread(filename));
}
configure(loadStories, module);
Error is following…
[withTheme] Please use ThemeProvider to be able to use withTheme
at WithTheme.componentWillMount (node_modules/styled-components/lib/hoc/withTheme.js:63:15)
at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:348:23
at measureLifeCyclePerf (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:75:12)
at ReactCompositeComponent.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:347:9)
at ReactCompositeComponent.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:258:21)
at Object.ReactReconciler.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:46:35)
at ReactCompositeComponent.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:371:34)
at ReactCompositeComponent.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:258:21)
at Object.ReactReconciler.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:46:35)
at mountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:55:31)
at ReactTestReconcileTransaction.TransactionImpl.perform (node_modules/react-test-renderer/lib/Transaction.js:140:20)
at batchedMountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:69:27)
at ReactDefaultBatchingStrategyTransaction.TransactionImpl.perform (node_modules/react-test-renderer/lib/Transaction.js:140:20)
at Object.ReactDefaultBatchingStrategy.batchedUpdates (node_modules/react-test-renderer/lib/ReactDefaultBatchingStrategy.js:62:26)
at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactUpdates.js:97:27)
at Object.ReactTestMount.render [as create] (node_modules/react-test-renderer/lib/ReactTestMount.js:125:18)
at Object.test (node_modules/@storybook/addon-storyshots/dist/test-bodies.js:26:44)
at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/index.js:141:21)
at process._tickCallback (internal/process/next_tick.js:103:7)
I’m using styled-components which expecting that I will use with HOC from this is quiet straightforward that hoc is not able to gather context data properly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Global addDecorator is ignored · Issue #10677 - GitHub
Describe the bug In my React/TypeScript app if I add a global addDecorator in my preview.tsx this is ignored. The exact same decorator...
Read more >How to add a global decorator in Storybook - Stack Overflow
Edit storybook/index.js, by using addDecorator on it. Example: import React from 'react' import { getStorybookUI, configure, addDecorator } ...
Read more >Decorators - Storybook - JS.ORG
A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators to augment your stories with extra...
Read more >Storybook Decorators for Angular - Medium
Apply your decorator to a story. Storybook parameters can be set at the level of a single story, a group of stories (a...
Read more >How to build a Storybook addon - Chromatic
loading. Varun Vachhar. Nov 13, 2020 — @winkerVSbecks ... Globals represent the “global” (as in not story-specific) context in Storybook.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@creaux did you try to put
addDecoratorinsideloadStories()as a workaround:@creaux I tried to reproduce with
@storybook/react v3.2.8such a simple global decorator:and it works fine for me. What version of Storybook do you use at this moment? Could you try to add this line into your
config.jsand check it out? Please, make sure that you manually update the page after each change since HMR doesn’t do it for a config files.