2016-08-01 3 views
0

django namedtupleのテーブルを作成したいのですが、エラーが発生しました。ヘッダー(これはリストです)はうまく動作します。django namedtupleの反応テーブルが返されます.mapは関数ではありません

views.pyUncaught TypeError: this.props.tableContent.map is not a function

info = [Info(id=5, location_id=861, f=None),Info(id=3, location_id=650, f=None)] 
return render('index.html', {'info': info}) 

index.html

var headers = ['id', 'location', 'f'] 

var Table = React.createClass({ 
    render: function() { 
     return (
      <table className="table-hover"> 
       {this.props.headers.map(function(name, index) { 
        return <th key={ index }>{name}</th>; 
       })}; 
       {this.props.tableContent.map(function(row, index) { 
        <tr key={index}> 
         return(
          {row.map(function(col, i) { 
           <td key={i}>{col}</td> 
          })} 
         ); 
        </tr> 
       })}; 
      </table> 
     ) 
    } 
}); 

ReactDOM.render(
    <Table headers={headers} tableContent={info}/>, 
    document.getElementById('content') 
); 

私は、任意の出力とコンソール言うを見ることができません。

答えて

0

データを受け取ったときにsafeを入れるのを忘れました。この問題に遭遇する可能性のある人にも。 thisもご参照ください

関連する問題