in React JS by
Q:

How to programmatically trigger click event in React?

1 Answer

0 votes
by

You could use the ref prop to acquire a reference to the underlying HTMLInputElement object through a callback, store the reference as a class property, then use that reference to later trigger a click from your event handlers using the HTMLElement.click method. This can be done in two steps:

  1. Create ref in render method:

    <input ref={input => this.inputElement = input} />
  2. Apply click event in your event handler:

    this.inputElement.click()
Click here to read more about React JS
Click here to read more about Insurance

Related questions

+1 vote
asked May 29, 2020 in React JS by anonymous
0 votes
asked Jan 31 in React JS by Robindeniel
0 votes
0 votes
asked Mar 4, 2020 in React JS by JackTerrance
+1 vote
+1 vote
asked Mar 2, 2020 in React JS by RShastri
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
...