当我从日期选择器中选择一个日期时,我想在Item
组件console.log(this.props.endDate)
中显示它,出现错误“范围无效时间”。我使用:https://www.npmjs.com/package/react-datepicker
class App extends Component {
constructor() {
super();
this.state = {
endDate: new Date()
};
}
handle = (date) => {
this.setState({
endDate: date
})
}
render() {
return (
<div>
<Item
endDate = {this.state.endDate}
handle = {this.handle}
/>
</div>
);
}
}
class Item extends Component {
constructor() {
super();
}
render() {
console.log(this.props.endDate)
return (
<div>
<DatePicker
selected={this.props.endDate}
onChange={this.props.handle()}
showTimeSelect
timeFormat="HH:mm"
timeIntervals={15}
dateFormat="MMMM d, yyyy h:mm aa"
timeCaption="time"
/>
</div>
);
}
}