Date does not change (from default date)
See original GitHub issueHi, I’m trying to set the state of a component with datepicker from a parent component. But the date or input never change from the default moment() date after clicking on another date on the picker, manual input with keyboard (it goes back to default onBlur), etc. The state does not change either according to React Console. Please note that the Placeholder Text is not showing either. Here is my code:
Parent Component:
constructor(props) {
super(props);
this.state = {
wants_interview_date: moment(),
}
}
handleDateChange(date) {
return (evt) => this.setState({ wants_interview_date: date });
}
return <ChildComponent
wants_interview_date={this.state.wants_interview_date}
onDateChange={this.handleDateChange} />;
Child Component:
<DatePicker
selected={this.props.wants_interview_date}
onChange={this.props.onDateChange}
className="form-control"
id="wants_interview_date"
placeholderText="Choose a Date"
/>
I am using Create-React-App
if that makes a difference. Any ideas or tips are welcome (ASAP!).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
How to Fix Excel Dates That Won't Change Format - Contextures
How to fix Excel dates that will not change format. Fix dates that end up in the wrong order when sorted. Use built-in...
Read more >Change the date system, format, or two-digit year interpretation
But formatting dates so that they are easy to understand is equally important to ensuring ... Change the default date format to display...
Read more >Change the default Date format in Excel
Change the default Date format · Step 1: Open the Regional setting · Step 2: Select another date format · Step 3: Change...
Read more >How to change Excel date format and create custom formatting
If you want to set a different default date and/or time formats on your computer, for example change the USA date format to...
Read more >Setting a Default Date Format in Excel - Causal
Once you've decided on the format, you need to go into the Excel options and select the 'Advanced' tab. In the 'Advanced' tab,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In addition to binding the callback to the component, in the provided code,
handleDateChange
is returning an anonymous function that is never invoked;setState
should be the only thing in the callback.