0
我有一個應用程序在React + Redux上運行,並且使用了redux-promise中間件來處理promise API調用。我想管理每個API調用的狀態(加載成功&錯誤)。因此,如the official documentation says我更改了applyMiddleware參數。Promise Redux:TypeError:下一個不是函數
import React from 'react';
import ReactDOM from 'react-dom';
import promiseMiddleware from 'redux-promise';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { Router, browserHistory } from 'react-router';
import reducers from './reducers';
import routes from './routes';
const createStoreWithMiddleware = applyMiddleware(
promiseMiddleware({
promiseTypeSuffixes: ['LOADING', 'SUCCESS', 'ERROR'],
}),
)(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<Router history={browserHistory} routes={routes} />
</Provider>
, document.querySelector('.container'));
但是,當我改變appyMiddleware我的應用程序不工作了,我有這樣的錯誤顯示在控制檯上:
TypeError: next is not a function
如果我變回這條線,一切正常,再次按預期。
const createStoreWithMiddleware = applyMiddleware(promiseMiddleware)(createStore); // App works again
怎麼了?
謝謝
感謝您的幫助。不幸的是,這並沒有解決錯誤:( – PJS