InputDateCustom.js
import DatePicker from 'react-toolbox/lib/date_picker/DatePicker'; import React, { Component } from 'react'; const datetime = new Date(2015, 10, 16); const min_datetime = new Date(new Date(datetime).setDate(8)); datetime.setHours(17); datetime.setMinutes(28); export default class InputDateCustomizado extends Component{ state = {date2: datetime}; handleChange = (item, value) => { console.log(item+" - "+value) this.setState({...this.state, [item]: value}); }; render() { return ( DatePicker label = {this.props.label} locale = {localeExample} name = {this.props.name} required = {this.props.required} onChange = {this.handleChange.bind(this, 'date1')} value = {this.state.date1} /> ); } }
other componet: Cadastro.js
constructor(props) { super(props); this.state = {msg: '', fim_vigencia:'', nome:''} this.setNome = this.setNome.bind(this) this.setFimVigencia = this.setFimVigencia.bind(this) } setFimVigencia(evento){ console.log("date") this.setState({fim_vigencia:evento.target.value}); }
<pre>
InputDateCustomizado
id="fim_vigencia"
label="Fim"
name="fim_vigencia"
value = {this.state.fim_vigencia}
onSubmit = {this.setFimVigencia}
/>
</pre>