我通过此操作启动加载扫描:
export function loadPickingScans (orderReference) {
return { type: SCANNING_LOAD_SCANS, orderReference };
}
它在我的智能(页面)组件中被调用:
componentDidMount() {
const { loadPickingScans } = this.props;
loadPickingScans(this.props.match.params.orderReference);
}
这是网址:
在此处输入代码
http://localhost:3000/orders/my-order-reference/scans
this.props.match.params.orderReference
正确包含 my-order-reference
。
但是,在我的操作中添加日志后,orderReference 会被接收为 未定义
。
What should I do to receive this expected value?
更新
根据要求:
function mapDispatchToProps(dispatch) {
return {
loadPickingScans: () => dispatch(loadPickingScans())
};
}
最佳答案
在mapDispatchToProps
中,在分派(dispatch)操作时,您没有向它传递任何参数,因此它在方法中记录未定义,您需要这样写
function mapDispatchToProps(dispatch) {
return {
loadPickingScans: (value) => dispatch(loadPickingScans(value))
};
}
或者简单地
const mapDispatchToProps = {
loadPickingScans
}
关于javascript - 参数值已发送至操作但未由操作接收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231169/