Understanding unique keys for array children in React.js

后端 未结 12 1301
时光取名叫无心
时光取名叫无心 2020-11-21 05:45

I\'m building a React component that accepts a JSON data source and creates a sortable table.
Each of the dynamic data rows has a unique key assigned to it but I\'m stil

12条回答
  •  说谎
    说谎 (楼主)
    2020-11-21 06:38

    var TableRowItem = React.createClass({
      render: function() {
    
        var td = function() {
            return this.props.columns.map(function(c, i) {
              return {this.props.data[c]};
            }, this);
          }.bind(this);
    
        return (
          { td(this.props.item) }
        )
      }
    });
    

    This will sove the problem.

提交回复
热议问题