I
I
IDONTSUDO2019-12-04 14:22:58
JavaScript
IDONTSUDO, 2019-12-04 14:22:58

REACT how to simulate a click?

let element =  document.getElementsByClassName('ant-select-selection__clear')
 element.click();
//способ 1
 document.querySelector("ant-select-selection__clear").click();
//способ 2

Pure.js didn't help.
How to simulate a user click event in React?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2019-12-04
@Casufi

React has synthetic events
https://reactjs.org/docs/handling-events.html
Why simulate a click when you can immediately call the handler function?
If you need to reach a real element in the house, you need to create a link to it and knock on the link
https://reactjs.org/docs/refs-and-the-dom.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question