I want to manually trigger a onclick event on a input element. I did some search and wrote the code as below.
<input type="date" ref={datePicker => this.datePicker = datePicker}/>
<button
onClick={(e) => {
this.datePicker.click()
}}>
Select the data
</button>
Then I also tried below code:
<input type="date" ref='datePicker'/>
<button
onClick={(e) => {
this.refs.datePicker.click()
}}>
Select the data
</button>
None of above code works. When I click the button , nothing happens. I expect to open the data picker ui.