【发布时间】:2018-12-17 02:09:57
【问题描述】:
我正在尝试根据当前状态更改更改 redux 存储,状态更改正确,但 this.props 仍然作为初始化。这是我的代码:
componentWillMount(){
this.props.fetchMatches();
}
handleChange(newDateRange){
console.log('====================================');
console.log('handleChange fired');
console.log(this.state);
console.log('====================================');
}
function mapDispatchToProps(dispatch) {
return {
handleChange: (newDateRange) =>
dispatch({
...this.props.home,
startDate: newDateRange[0],
endDate: newDateRange[1]
})
}
}
export default connect(mapStateToProps, { mapDispatchToProps, fetchMatches })(Home);
这是DateRange的实现:
<DateRangeInput className="daterange" value={[this.props.startDate, this.props.endDate]} onChange={this.handleChange} />
【问题讨论】:
标签: javascript reactjs redux react-redux redux-thunk