【发布时间】:2020-01-05 23:05:05
【问题描述】:
我在 ComponentDidMount 中调用了 3 个操作,但结果是 保存在最后一个被调用的动作中
componentDidMount() {
if (this.props.auth.token !== undefined) {
this.props.getBillsRequest(this.props.auth.token)
this.props.getProfile(this.props.auth.token)
this.props.getInstallmentsRequest(this.props.auth.token)
console.log(this.props)
} else {
this.props.navigation.navigate("Login")
}
}
预期的输出是
bills : {items: object}
profile: {user: object, detail: object}
installments: {0: object, 1:object , ...}
但我得到了
bills: {items: undefined}
profile: {user: undefined}
installments: {items: object, profile: object, biils: object}
【问题讨论】:
-
能否请您先将所有逻辑移出reducer,并按照标准保持纯函数?
-
不要发图片;发布一个最小的代码示例。看看writing the perfect question。
-
无法在 utils 中移动逻辑
标签: javascript react-native redux