I'm trying to select an id using a onClick method, the only problem is that when i click a button only the last id is displayed.
const renderTableData = () => {
let id = 0;
return (
  <tr>
    {days.map((val) => (
      <td>
        {timeSlot.map((time, i) => {
          if (occupiedSlots().result.includes(id + 1)) {
            return (
              <button id={id++} className="disabledButton">
                {time}
              </button>
            );
          } else {
            return (
              <button id={id++} className="activeButton" onClick ={() => {canBookSlot({id})}}> 
                {time}
              </button>
            );
          }
        })}
      </td>
    ))}
  </tr>
);
};
This is what the canBookSlot() function looks like:
 const canBookSlot = (id) => {
let userDetailsString = localStorage.getItem("userDetails");
const userDetailsObj = JSON.parse(userDetailsString)
if(userDetailsObj.canBook != 0){
      Axios.post('http://localhost:3001/api/book/week1/ex', {
         room: userDetailsObj.room,
         id: id
    })
    return console.log(id) 
} else {
  return console.log("somethings wrong")
}
};
The output is always 70. how do i fix this?
 
     
    