Question: I am new in react. I need use [react-datepicker](https://github.com/Hacker0x01/react-datepicker)

I want to get value of input, when I change date.
If i click on 20th October 2017, i want put 20th October 2017 in my variable.
But the main problem that I should work with component, not with input.

Before I just took value from state. Like this.state.value. But right now it is object(Moment) in state. And this object doesn't have value field. 

There is my code:

```
export default class DatePicker extends Component {
constructor (props) {
    super(props);
    // this.props.date should looks like "29 November 2017 00:00"
    // second argument for moment() it is format of date, because RFC 2822 date time format
    this.state = {
        date: moment(this.props.value, 'LLL')
    };
}
handleChange = (date) => {
  // const valueOfInput = this.state.date  <--- I want string with date here
  console.log('this.state.date',this.state.date);
  this.setState({date: date});
};
render() {
    return <Form.Field>
              <Label>
                <Picker
                  selected={this.state.date}
                  onChange={this.handleChange}
                  dateFormat="LLL"
                  locale={this.props.language}
                />
              </Label>
          </Form.Field>

```

[![enter image description here](https://i.stack.imgur.com/T3lRi.png)](https://i.stack.imgur.com/T3lRi.png)

Answer: 
Try this 

```
<DatePicker 
   onChange={(value, e) => this.handleChange(value, e)}
   selected={this.state.inputValue} otherProps={here} 
/>

// you can access the value field in handleChange by e.target.value

handleChange(value, e) {
    console.log(value); // this will be a moment date object
    console.log(e.target.value); // this will be a string value in datepicker input field
}

```
I have same problem, and I solved it by using the below solution. Please try it:

```
<p>{this.state.date.toLocaleDateString()}</p>

```