Answer the question
In order to leave comments, you need to log in
How to override event handler when inheriting in React?
Let's say we have a component
class Dropdown1 extends React.component {
onClickHandler(e) {
console.log(e.target.innerText)
}
render() {
return (
<ul>
{[1, 2, 3].map((number, i) =>
<li key={i} onClick={this.onClickHandler}>{number}</li>)
}
</ul>
)}
}
<li>0</li>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question