Add post written in javascript to demonstrate new js frontmatter capability
This commit is contained in:
parent
066a0cea86
commit
e333cb1aad
5 changed files with 393 additions and 289 deletions
41
pages/2016-12-9-react-component-post/single-date-picker.js
Normal file
41
pages/2016-12-9-react-component-post/single-date-picker.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import React from 'react';
|
||||
|
||||
import SingleDatePicker from 'react-dates/lib/components/SingleDatePicker';
|
||||
|
||||
class SingleDatePickerWrapper extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
focused: false,
|
||||
date: null,
|
||||
};
|
||||
|
||||
this.onDateChange = this.onDateChange.bind(this);
|
||||
this.onFocusChange = this.onFocusChange.bind(this);
|
||||
}
|
||||
|
||||
onDateChange(date) {
|
||||
this.setState({ date });
|
||||
}
|
||||
|
||||
onFocusChange({ focused }) {
|
||||
this.setState({ focused });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { focused, date } = this.state;
|
||||
|
||||
return (
|
||||
<SingleDatePicker
|
||||
{...this.props}
|
||||
id="date_input"
|
||||
date={date}
|
||||
focused={focused}
|
||||
onDateChange={this.onDateChange}
|
||||
onFocusChange={this.onFocusChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SingleDatePickerWrapper;
|
||||
Loading…
Add table
Add a link
Reference in a new issue