'React - ES6 way' of binding click handlers with parameters

后端 未结 5 2084
暗喜
暗喜 2021-02-09 12:52

I\'ve read a bunch of articles about the use of () => {} syntax, binding in the constructor, binding in the props etc.. but from what I understand, binding

5条回答
  •  礼貌的吻别
    2021-02-09 13:24

    If passing a parameter then you must bind in the render function and not in the constructor. This can be done using the bind or an arrow function.

  • {item.name}
  • or

  • this.handleClick(item.id)} />{item.name}
提交回复
热议问题