var initialState = Map({
status: true
});
function user(state = initialState, action) {
switch (action.type) {
case GET_PROFILE:
return state.set(fromJS(action.response))
}
})
API集狀態返回JSON - >action.response
{
"id": 11,
"profileImage": "http://www.surfertoday.com/images/stories/addictivesurfing.jpg"
}
問題:fromJS
設置,而不是一個新的Map
對象,將數據添加到現有Map
。我試圖做一些像 return state.set(Array(fromJS(action.response)))
這不起作用。
我該如何解決這個問題?或者我不應該使用Immutable.js?
使用'merge',而不是'set' – user6227254