Reactjs - Todo App, Remove Items From List
I'm not sure what I am doing wrong here. ReactJS is pretty new to me, so I need some help into the right direction. What I want to achieve is when the span is clicked on a single l
Solution 1:
varTodoItems = React.createClass({
render: function() {
var todoEntries = this.props.entries;
functioncreateTasks(item) {
return<likey={item.key}>{item.text}<spanonClick={() => this.props.remove(item.key)}>X</span></li>;
}
var listItems = todoEntries.map(createTasks,this);
return (
<ulclassName="theList">
{listItems}
</ul>
);
}
});
Solution 2:
change <span onClick={this.props.handleRemove(item.key)
to <span onClick={this.props.remove(item.key)
the props name is remove not handleRemove
and do todoEntries.map(createTasks, this);
also this.props.remove.bind(this, item.key)
Post a Comment for "Reactjs - Todo App, Remove Items From List"