I'm new to React and stuck trying assign parent's function to children created dynamically
class Row extends React.Component {
handleStateChange() {
console.log(this); //just for test
}
render() {
let notes = [],
categoryId = this.props.rowNo;
bonuses.forEach(function (bonus, i) {
let id = 'cell_' + categoryId.toString() + (i + 1).toString();
notes.push(<NoteCell bonus={bonus}
songName={id + '.mp3'}
id={id}
key={id}
// that is the point
handleRowStateChange={this.handleStateChange}
/>);
});
return (
<div className="row clearfix">
{notes}
</div>
)
}
I get Cannot read property 'handleStateChange' of undefined error.
What am i doing wrong?