【发布时间】:2016-05-21 21:14:22
【问题描述】:
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"}。有什么我遗漏的吗?
【问题讨论】:
-
也许您确实将一个空对象明确传递给
currentUser?默认值仅在您传递undefined时出现。请告诉我们电话。 -
这看起来像一个 redux 应用程序。
{}可能正在传入。
标签: javascript ecmascript-6 redux