Skip to content

Instantly share code, notes, and snippets.

@xarxziux
Created September 22, 2017 15:28
Show Gist options
  • Save xarxziux/d13f8fe55b31191103b1069a3e0bc867 to your computer and use it in GitHub Desktop.
Save xarxziux/d13f8fe55b31191103b1069a3e0bc867 to your computer and use it in GitHub Desktop.
const React = require ('React');
const DatePickerMain = require ('react-datepicker');
let sendDate = () => {};
class DatePicker extends React.Component {
constructor (props) {
super(props);
this.state = {
startDate: null
};
this.handleChange = this.handleChange.bind(this);
}
handleChange (date) {
this.setState({
startDate: date
});
sendDate (date);
}
render () {
return <DatePickerMain
selected={this.state.startDate}
onChange={this.handleChange}
/>;
}
}
module.exports = changeEvent => {
if (typeof changeEvent === 'function')
sendDate = changeEvent;
return <DatePicker />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment