Answer the question
In order to leave comments, you need to log in
ReactJs how to pull the object to which the event is attached?
Tell me how you can pull out the object to which the event is attached?
For example:
handleTouchStart = (e) => {
// как вытащить ссылку на объект div к которому привязано событие onTouchStart?
// e.target - вытаскивает объект на котором нажали в данном случае будет h1
}
render () {
return <div onTouchStart={this.handleTouchStart}><h1>Контент</h1></div>;
}
Answer the question
In order to leave comments, you need to log in
by preventDefault: Link
Read immediately the answer there.
By the way, what is your goal? Maybe I can suggest another implementation. For example, if you want, depending on what you clicked, to divide in your function, then it is better to pass some parameter in the function call.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question