我使用react-bootstrap-datetimerangepicker库与bind()从日历中获取选定的日期,但该库的'onApply'函数传递2个参数(事件,选择器),并在'预定义'我没有得到startDate和endDate,假设它会在第二个参数中出现。而如果没有绑定它不工作无法使用预定义的绑定功能
<DatetimeRangePicker
timePicker
showDropdowns
timePicker24Hour
onApply={this.handleChange.bind(this, 'predefined')} />
handleChange(event, picker) {
this.props.sendDateRanges(payload);
}
https://github.com/luqin/react-bootstrap-datetimerangepicker
谢谢,@ kngroo。这工作,但通过在点击应用按钮上使用handleChange()函数,我试图调用redux以反映选择器中的日期更改,但直到reducer我得到新的选定日期,但没有在选择器中,因此没有更新获取componentWillReceiveProps()中的nextprops 。你能告诉我错过了什么吗? – NSh
不看代码就很难调试你的问题。如果你想在redux中存储和更新日期选择器的值,你需要通过调用'picker'数据调用redux的调度方法来调用handleChange函数中的一个动作。假设您的redux设置正确完成,您需要确保您的组件与redux“连接”。 '连接(mapStateToProps)(YourComponent)' – kngroo
https://stackoverflow.com/questions/46636800/react-selector-is-not-been-called在这里我发布的问题,我确实调用了redux – NSh