Redux 正在抛出我:
错误:预期化简器是一个函数。 在行
从索引:
const { store } = configureStore();
从配置存储:
const store = createStore(rootReducer, initialState, devToolsEnhancer())
索引.js
import React from 'react';
import { render } from 'react-dom';
import Root from './Root';
import './index.css';
import App from './whitesheet-components/App';
import registerServiceWorker from './registerServiceWorker';
import configureStore from './store/configureStore';
const { store } = configureStore();
const MOUNT_NODE = document.getElementById('root');
const load = Component =>
render(
<App>
<Component store={store} />
</App>,
MOUNT_NODE,
);
load(Root);
registerServiceWorker();
配置存储.js
import { createStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension';
import rootReducer from './rootReducer';
const isDevelopment = process.env.NODE_ENV !== 'production';
export default function configureStore(initialState = {}) {
const store = createStore(rootReducer, initialState, devToolsEnhancer());
if (isDevelopment && module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./rootReducer.js', () => {
const nextReducer = require('./rootReducer').default; // eslint-disable-line global-require
store.replaceReducer(nextReducer);
});
}
return { store };
}
根减速器
import mockReducer from './mockReducer';
export default { mockReducer };
模拟减速机
export default function reducer(state = { hola: 'as' }, { type }) {
switch (type) {
default:
return state;
}
}
找不到错误。第一次自己使用devtools插件支持创建redux商店
看起来您正在导出根化简器中的对象而不是函数。
根减速器
import mockReducer from './mockReducer';
// export default { mockReducer };
export default mockReducer;