I'm trying to get the value from my <li>
tag in render but getting the undefined end result. I changed the code according to the suggested answers and now I got the result null.
handleClick= (e) => {
console.log(e.target.getAttribute('device'));
}
render() {
let { deviceData } = this.state;
return (
<React.Fragment>
{deviceData.map((result,i) => (
<li key={i} className="nav-item" onClick= {this.handleClick} device= {result.device_title}>
<a href="#" className="nav-link" >
<i className="nav-icon fas fa-archway" />
<p>
{result.device_title}
</p>
</a>
</li>
))}
</React.Fragment>
)
}