I want to display the date and time selected by the user from date-time picker on my UI . My code is as follows-
import React from 'react';
import '../App.css';
import Datetime from 'react-datetime';
class Datetimepicker extends React.Component {
constructor(props) {
super(props);
this.state = {
moveaside: false,
feed_items: [],
newText: new Date(),
};
this.updateState = this.updateState.bind(this);
this.showValuee = this.showValuee.bind(this);
}
updateState(e) {
const text = e.value;
console.log("text", text);
this.setState({ newText: text });
this.showValuee();
}
showValuee() {
console.log(this.state.newText);
}
render() {
console.log(this.props.value);
return (
<Datetime className={this.props.show ? 'rdt' : 'hide'} onChange={this.updateState} defaultValue={this.state.newText} />
)
}
}
export default Datetimepicker;
'text' shows undefined value.I am importing this 'Datetimepicker' component in my parent component and the Datetime picker I am using is this - (https://github.com/YouCanBookMe/react-datetime)