I want to add an on click function to the cells of my table. The function should give me the value of the clicked cell. When the table initialize the function will be called automatically for each Cell, but after this the cells are not clickable.
My table: The values of the map are simple Strings ( "test1", "test2", ...)
renderTableData() {
return this.props.skills.map((skill) => {
const { id, name } = skill;
return (
<tr key={id}>
<td className="cell-hyphens " onClick={getContent(name)}>
{name}
</td>
</tr>
);
});
}
This is the simple function:
function getContent(content) {
alert(content);
}