I am brand new to React and almost everything related to it. I am still learning the MVC pattern. I am just taking the examples on the React homepage and trying to extend them, but I'm running into an error when I try to add a "onClick" to a span tag that I'm including with every todo.
Here is what I'm doing: https://jsfiddle.net/69z2wepo/11884/
And here is the offending code block:
var TodoList = React.createClass({
markComplete: function(event){
alert("geelo");
},
render: function(){
var createItem = function(itemText, index){
return (
<li key={index + itemText}>
{itemText}<span id="markComplete" onClick={this.markComplete}>X</span>
</li>
);
};
return <ul id="list-container">{this.props.items.map(createItem)}</ul>
}
});
Specifically I'm trying to get markComplete to fire from the following onClick={this.markComplete}
If I click on the "markComplete" span I get the following error:
Error: Invariant Violation: Expected onClick listener to be a function, instead got type object.
I can not find a solution on my own, and I've been struggling for awhile and I was hoping someone could point me in the right direction. I would be very grateful! Thank you so much!