const initialState = {
username: "default"
}
export function currentUser(state = initialState, action) {
switch (action.type) {
case constants.SET_CURRENT_USER:
console.log(state)
console.log(initialState)
debugger
return _.extend({}, state, action.user)
当我打印state
时,我得到一个空对象而不是{username: "default"}
。有什么我想念的吗?
答案 0 :(得分:3)
使用类似代码在chrome控制台中进行快速测试可以得到预期的结果,而不是报告的错误。
也许你真的用空对象调用了函数?