【发布时间】:2020-12-15 11:05:53
【问题描述】:
今天我遇到了一个让我发疯的错误!我正在使用 react with redux ,以前从未见过这样的错误。问题是我的redux调度函数的“第二个参数”总是返回我所有的REDUX状态,所有其他参数都在工作并返回我他们必须返回的东西!除了 2ND 谁总是返回所有的状态?这是什么魔法
this.props.sendPushNotification(); // even with empty parameters return the second parameters with all the redux state
const mapDispatchToProps = dispatch => ({
sendPushNotification: dispatch.notifications.sendPushNotification,
});
// my redux function
async sendPushNotification (token, title , body , data) {
console.log(token) // return undefined
console.log(title) // ALWAYS RETURN ALL THE STATE / PROPS FROM REDUX EVEN IF THERE IS NO PARAMETERS
console.log(body) // return undefined
console.log(data) // return undefined
}
【问题讨论】:
-
为什么不抛出:
sendPushNotification: dispatch.notifications.sendPushNotification?当尝试将dispatch.notifications.sendPushNotification()作为函数执行时,这肯定会引发异常。 -
它什么都没扔?
-
为什么要抛出异常?