question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple SingleDatePicker on the same form not working

See original GitHub issue

When I put two SingleDatePicker in a form, only one picker is working.

<SingleDatePicker date={this.state.date2} onDateChange={date2 => this.setState({ date2 })} focused={this.state.focused2} onFocusChange={({ focused2 }) => this.setState({ focused2 })} />

<SingleDatePicker date={this.state.date} onDateChange={date => this.setState({ date })} focused={this.state.focused} onFocusChange={({ focused }) => this.setState({ focused })} placeholder="DATE OF BIRTH" required showDefaultInputIcon numberOfMonths={1} />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
majapwcommented, Jun 28, 2017

@ljharb is right (https://github.com/airbnb/react-dates/blob/master/src/components/SingleDatePicker.jsx#L42 for the updated line)

However, the real issue is that instead of

onFocusChange={({ focused2 }) => this.setState({ focused2 })} 

you should probably do:

onFocusChange={({ focused: focused2 }) => this.setState({ focused2 })}

The onFocusChange callback passed back an object with a focused key, not a focused2 key.

0reactions
Buddhimalcommented, Mar 4, 2019

@ljharb is right (https://github.com/airbnb/react-dates/blob/master/src/components/SingleDatePicker.jsx#L42 for the updated line)

However, the real issue is that instead of

onFocusChange={({ focused2 }) => this.setState({ focused2 })} 

you should probably do:

onFocusChange={({ focused: focused2 }) => this.setState({ focused2 })}

The onFocusChange callback passed back an object with a focused key, not a focused2 key.

Thanks it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple SingleDatePicker on the same form not working #599
When I put two SingleDatePicker in a form, only one picker is working. <SingleDatePicker date={this.state.date2} onDateChange={date2 => this ...
Read more >
React-Date "SingleDatePicker" not working as expected?
I had exact the same problem when integration react-dates into my project, and I believe the root cause is that the css module...
Read more >
Date | Multiple Months | JET Developer Cookbook - Oracle
This JET InputDate demo provides an example of showing multiple months in a single datepicker if the screen resolution is at least 768px....
Read more >
Date Range Picker - MundoScotia
Originally created for reports at Improvely, the Date Range Picker can be attached to any webpage element to pop up two calendars for...
Read more >
Date picker validation in multi-row does not work - Laracasts
type · "text" ; name · "addmore[0][from]" ; placeholder · "" ; class · "form-control" ; value · "" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found