這裏我試圖在組件中顯示源代碼,但總是發現錯誤,因爲state.get
不是函數。當試圖映射react-redux狀態時,state.get不是函數
reducer.js
let initialState = Immutable.fromJS({sources: []});
export default function (state = initialState, action){
switch(action.type){
case GetSources:
return state.merge({
sources: action.sources
});
break;
}
return state;
}
Component.js
function mapStateToProps(state){
return{
sources: state.get('sources')
}
}
allReducers.js
您是否在某處使用'combineReducers'? –
'state'對象是什麼樣的:S? – JonE
我的狀態對象如下所示:Object {sources:Map,news:Object} – Candy