Here the List get's 'n' values from the app.component. I am trying to write onclick function for each of the buttton. Here, is the code
onChildButtonClick = (val) => {
console.log(val);}
function makeButton(data) {
return (
<button onClick = {this.onChildButtonClick.bind(null, data.name)} >
{data.name} </button>
);}
const List = (props) => {
const {projectnames} = props
return (
<tr>
<div> {
projectnames.map(makeButton, this)
}
</div>
</tr>
)
}
When I try to execute it throws me an error onChildButtonClick is not defined.