Làm thế nào để truyền một parameter vào một event handler hoặc callback?

{{FormatNumbertoThousand(model.total_like)}} lượt thích
2.138 lượt xem
Reactjs junior

Bạn có thể sử dụng arrow function để bao quanh một event handler và truyền các tham số:

<button onClick={() => this.handleClick(id)} />

hoặc sử dụng .bind:

<button onClick={this.handleClick.bind(this, id)} />
Câu hỏi tiếp theo: Higher-Order component là gì?
{{login.error}}