【发布时间】:2018-11-30 18:56:57
【问题描述】:
我想将 React 组件(称为 ApplicationForm)添加到 storybook。
故事书是这样写的:
import { configureStore } from '../store';
const store = configureStore();
storiesOf('application from', module)
.addDecorator(story => <Provider store={store}>{story()} </Provider>)
.add('all', () => (
<ApplicationForm />
));
ApplicationForm 是用 reduxForm 创建的。这就是为什么我需要在addDecorator 函数中提供store。
不幸的是,在 configureStore 函数中,reducer 之一具有全局数据 window.GLOBAL 的依赖关系。
在故事书中我会看到以下错误:
GLOBAL is not defined
ReferenceError: GLOBAL is not defined
at initGlobalState (http://localhost:9010/static/preview.bundle.js:86625:3)
如何在故事书中注入或模拟此类全局数据?
【问题讨论】: