I need to open/close calendar dropdown on click of an external button. I am maintaining a local state flag "startOpenFlag" which is false by default. And in my
On click of myButton i am setting this flag to true. But, calendar dropdown doesn't seem to open.
Any help appreciated.
You can use setOpen(bool) method. Just set ref property to DatePicker component and call setOpen, for example:
toggle = () => {
this.component.setOpen(this.focus);
this.focus = !this.focus;
}
...
<DatePicker
ref={(r) => {
this.component = r;
}}
autoFocus
selected={this.state.startDate}
onChange={this.handleChange}
/>
<button type="button" onClick={() => this.toggle()}>toggle</button>
I added a custom input.
customInput={
class CustomInput extends React.Component {
render () {
return (
This works like a charm! Thanks for your help though. :) Closing this issue.
Most helpful comment
You can use
setOpen(bool)method. Just setrefproperty to DatePicker component and callsetOpen, for example: