score:1

Accepted answer
render(){
    var items = this.props.items.map((todo, index) => {
        return (
            <Item
            key={index}
            todo={todo}
            onDeleteItem={this.onDeleteItem.bind(this)} />
        )
    })
    return (
        <div>{items}</div>
    )
}

score:0

class ItemList extends Component{
constructor(props){
    super(props);
}

onDeleteItem(event){
    var indexNum = this.props.items.indexOf(document.querySelector(".ion-trash-b").parentElement.textContent)

}

render(){
    var items = this.props.items.map(function(todo, index){
        return (
            <Item
            key={index}
            todo={todo}
            onDeleteItem={this.onDeleteItem.bind(this)} />
        )
    }.bind(this)
    return (
        <div>{items}</div>
    )
}

score:0

class ItemList extends Component{
    constructor(props){
        super(props);

        // bind method once per ItemList instance
        this.onDeleteItem = this.onDeleteItem.bind(this);
    }

    render(){
        var onDeleteItem = this.onDeleteItem

        var items = this.props.items.map(function(todo, index){
            return (
                <Item
                key={index}
                todo={todo}
                {/* you don't need this here */}
                onDeleteItem={onDeleteItem} />
            )
        })
        return (
            <div>{items}</div>
        )
    }
}

score:2

var items = this.props.items.map(function(todo, index) {
    return (
        <Item
            key={index}
            todo={todo}
            onDeleteItem={this.onDeleteItem.bind(this)} />
    )
}.bind(this))

Related Query

More Query from same tag