Reactコンポーネントのrender
機能で使用するためにテーブル行を動的に作成しようとしています。私が理解する限り、React.createElement
関数を使用して要素を作成することはできますが、動的に生成された一連の要素を連鎖して属性を設定する方法は不明です。例えば:あなたが子供TDの簡単にこのようなとTRを作成することができReact - 属性を持つ要素を動的に作成し、それを別の要素にネストする方法はありますか?
var cols = this.props.array_of_col_objects;
var react_col_array = [];
var row = React.createElement("tr");
for(c=0;c<cols.length;c++){
var col = React.createElement("td");
// how to set the attributes of this element, e.g. className, id, etc.
react_col_array.push(col);
}
// How do i now insert the generated column elements into the row element?
React初めての方は、JSXの代わりにJSXを使用することをおすすめします。 'createElement'です。ドキュメンテーションとサンプルコードの後には、はるかに簡単な時間があります。 –