ReactJS – React datepicker How to open DatePicker when you click on the icon

Try to open the datepicker and click on the icon of the react-datepicker component. I have completed their documentation and question links, but found that it is not very useful.

 {...startDateOpts}
id='abc'
maxDate={moment()}
onChange={this.handleStartChange}
placeholderText='Start Date'
popoverAttachment={smallScreen?'bottom center': undefined}
popoverTargetAttachment={smallScreen?'top center': undefined}
popoverTargetOffset={smallScreen ? '0px 0px': undefined}
/>

enter image description here

I tried from React-datepicker docs link but no luck.

Just use a label to wrap the DatePicker. All clicks on the internal label call are focused on the input, that is, open the calendar.

Try to open the datepicker and click on the icon of the react-datepicker component. I have completed their documentation and question links, but found that it is not much Useful.

 {...startDateOpts}
id='abc'
maxDate={moment()}
onChange={this.handleStartChange}
placeholderText='Start Date'
popoverAttachment={smallScreen?'bottom center': undefined}
popoverTargetAttachment={smallScreen?'top center': undefined}
popoverTargetOffset={smallScreen? '0px 0px': undefined}
/>

enter image description here

Me Tried from the React-datepicker docs link but no luck.

Just wrap the DatePicker with a tag. All clicks on the inner tag call are focused on the input, that is, the calendar is opened.

Leave a Comment

Your email address will not be published.