未定义不是函数(在'... action.account.map ...'附近)

时间:2020-07-21 09:04:14

标签: react-native redux react-redux

我不断收到此错误,我也不知道为什么。所有代码似乎都适合我,但是我看不到我的错误。我是React-Native的新手,也是Redux的新手。如果您能帮助我,我将不胜感激。

const initialState = {
    account: [],
}
const addAccount = (state = initialState, action) => {
    switch (action.type) {
        case SET_ACCOUNT:
            return {
                account: action.account.map(
                    (cb) => newAccount = { id: cb.id.toString(), name: cb.name, imageUri: cb.imageUri, email: cb.email, password: cb.password })

            }
        default:
            return state
    }
}

1 个答案:

答案 0 :(得分:0)

应该是

action.payload.account.map

Action具有两个属性有效负载和类型。 开关中使用类型,您将对象作为有效载荷发送