Skip to content

Instantly share code, notes, and snippets.

@bholzer bholzer/infinite.jsx
Created Aug 16, 2017

Embed
What would you like to do?
class DateVerifier extends React.Component {
constructor(props) {
super(props)
this.state = {
dob: null
}
}
render() {
return (
<DateInput onDateChange={(val) => this.setState({ dob: value })} />
)
}
}
class DateInput extends React.Component {
constructor(props) {
super(props)
this.state = {
day: null,
month: null,
year: null
}
}
handleInputChange(event) {
const target = event.target
const name = target.name
this.setState({
[name]: target.value
})
}
componentDidUpdate() {
const date = moment([this.state.year, this.state.month, this.state.day]);
this.props.onDateChange(date.format('MM-DD-YYYY'));
}
render() {
return (
<input name="day" onChange={this.handleInputChange.bind(this)} />
<input name="month" onChange={this.handleInputChange.bind(this)} />
<input name="year" onChange={this.handleInputChange.bind(this)} />
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.