I am using Javascript and React to build a front end. I am not sure how to reference a method of the containing object:
var RAttribute = React.createClass({
loadAssignmentsForList: function(elem) {
//other code
},
render: function() {
var assignmentsLoading = this.props.assignmentsLoading;
var lists = this.props.data.lists.map(function(elem) {
return (<li className='list-group-item grey'>
<div className='list-group'>
<RList key = {elem.name} data={elem}
assignmentsLoading={assignmentsLoading}
loadAssignmentsForList={this.loadAssignmentsForList(elem)}/>
</div>
</li>);
});
//other code
}
//other code
});
I am trying to call loadAssignmentsForList
from within render
so I am using this.loadAssignmentsForList(elem)
. However, I get the following error.
Uncaught TypeError: Cannot read property 'loadAssignmentsForList' of undefined