Say I have a render function that looks like this:
render() {
var user_rows = []
this.state.user_list.forEach(function (user, index){
user_rows.push(
<tr key={user}>
<td><div className="btn-toolbar"><button type="button" onClick={this.editUser.(usesr.sso)} className="btn btn-success-outline">Edit</button></div></td>
</tr>)
})
return (<tbody>
{user_rows}
</tbody>)
I get the error:
Uncaught TypeError: Cannot read property 'editUser' of undefined
I would like like the onClick to:
1. Not run when the component is created, only run when actually clicked
2. bind to the function within this component properly
I tried:
onClick={this.editUser.bind(null, user.sso)}, but didn't seem to work in this case.