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