How to access custom attributes from event object in React?

前端 未结 15 2033
不思量自难忘°
不思量自难忘° 2020-11-27 09:27

React is able to render custom attributes as described at http://facebook.github.io/react/docs/jsx-gotchas.html:

If you want to use a custom attribut

15条回答
  •  清酒与你
    2020-11-27 10:02

    As of React v16.1.1 (2017), here is the official solution: https://reactjs.org/docs/handling-events.html#passing-arguments-to-event-handlers

    TLDR: OP should do:

    render: function() {
    ...
     this.removeTag(i, e)}>
    ...
    removeTag: function(i, event) {
        this.setState({inputVal: i}); 
    }
    

提交回复
热议问题