Comment

Comment by positivecomment

Is there special logic in react that binds arguments of a function to the props with the same name? I'm talking about the handleDelete "fix" in the article:

    render() {
        const views = this .props.dataList.map((d, i) => {
            return <Data data={d} index={i} onDelete={this.handleDelete} />
        });
    }
    handleDelete(index) {
        //...
    }
I guess they just call that function from within the Data component with the correct parameter. But then, Data component needs to know how to call that function. Is there a better way?

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton