0
嘗試從行動減速不是函數
創建減速昂獲取的數據,但在控制檯中看到的錯誤:減速機是不是一個函數.....
我減速機:
import { INCOME_LIST } from '../actionTypes'
import Immutable from 'immutable'
const initialUserState = {
list: []
}
const listReducer = function(state = initialUserState, action) {
switch(action.type) {
case 'INCOME_LIST':
return Object.assign({}, state, { list: action.data });
}
return state;
}
我哪裏有錯誤?
我的行動:
import axios from 'axios'
import { INCOME_LIST } from '../actionTypes'
function receiveData(json) {
return{
type: INCOME_LIST,
data: json
}
};
export function IncomeList() {
return dispatch => {
return (
axios.post('http://139.196.141.166:8084/course/income/outline',{}, {
headers: { 'X-Authenticated-Userid': '[email protected]' }
}).then(function (response) {
dispatch(receiveData(response.data));
})
)
}
}
它是如何正確的方式爲創建減速?
你導出了'listReducer'嗎? – Giladd
謝謝...需要導出 –