How can I access a data attribute associated with a button from the onClick event handler of the button? Please see the code snippet below.
function ComponentWithAttribute () {
function OnClicked() {
alert("Value of data-val here");
}
return (
<button
onClick={OnClicked}
data-value={'foo'}
>
Click Me!
</button>
)
}
export default ComponentWithAttribute;