我已经插入了一个中间件redux-thunk,我想添加另一个redux-logger。
如何配置它,以便我的应用程序同时使用两种中间件?我尝试传递一个数组,[ReduxThunk, logger]
但是没有用。
码:
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import logger from 'redux-logger';
import App from './components/app';
import reducers from './reducers';
require('./style.scss');
const createStoreWithMiddleware = applyMiddleware(ReduxThunk)(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>,
document.querySelector('#app')
);
安迪的答案是好的,但是,考虑到您的中间件正在增长,下面的代码会更好: