I was wondering if there is a simple way to get an attribute of clicked element in React.js:
function App () {
return (
<button
title={'foo'}
onClick={myFunction(this)}
>
click me
</button>
)
}
function myFunction(e) {
alert(e.getAttribute('title'));
}
Right now I'm getting: TypeError: can't access property "getAttribute", e is undefined.
I need it inside a function for pass the attribute into another (working) function later on.
e.target.getAttribute?this, it doesn't refer to the click event