I am trying to get the id of the button clicked in React and this is the code I've written:
const saveid = (e) => {
console.log(e.target.id);
}
<Button className='gettheid' onClick={(e)=>saveid(e)} id={something[i][0]} variant="contained" color="primary">
The console.log I've written in saveid sometimes gives the id but sometimes it doesn't. I am unable to figure out why. Can someone help me out