[英]React redux dispatch issue
I'm trying to dispatch a function from a component which has route 'localhost:8080/location/:id' but it seems to give an error, the same dispatch function is working in other component which doesn't have param id. 我正在尝试从具有路由'localhost:8080 / location /:id'的组件调度一个函数,但它似乎给出了一个错误,相同的调度函数在其他没有param id的组件中工作。
This is error i'm getting while dispatching that action. 这是我在调度该操作时遇到的错误。
Uncaught TypeError: (0 , _bandwidth2.default) is not a function
未捕获的TypeError:(0,_bandwidth2.default)不是函数
This is my dispatchToProps. 这是我的dispatchToProps。
const mapDispatchToProps = (dispatch) => ({
addBandwidth: (bandwidth) => dispatch(addBandwidth(bandwidth))
});
export default connect(undefined, mapDispatchToProps)(UpgradeBandwidth);
This is my action. 这是我的行动。
export const addBandwidth = (bandwidth) => ({
type: 'ADD_BANDWIDTH',
bandwidth
});
Just to clarify, this function working in other component but not in one which has param id in its route. 只是为了澄清一下,这个函数在其他组件中工作,但不在其路径中具有参数id的组件中。 Please help.
请帮忙。 Thanks.
谢谢。
This is where i called. 这是我打电话的地方。
handleSubmit = (e) => {
e.preventDefault();
console.log(this.state)
this.props.addBandwidth({
_id: uuid(),
leasedCircuitId: this.state.leasedCircuitId,
bandwidth: this.state.bandwidth,
bandwidthUnit: this.state.bandwidthUnit,
bandwidthType: this.state.bandwidthType,
lastMile: this.state.lastMile,
remarks: this.state.remarks,
discountPolicy: this.state.discountPolicy,
status: false
});
}
检查你的App.js你是否确实导入了addBandwidth()?
import { addBandwidth } from 'path to your action'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.