fixed-data-tableを使用して、React に次の SSCCE があります。
const rows = [{name: 'Apple', desc: 'a popular fruit'},
{name: 'Cat', desc: 'a domesticated feline'}];
const App = React.createClass({
render: function() {
return (
<Table id='foo'
height={200}
width={400}
rowsCount={rows.length}
rowHeight={26}
headerHeight={50}>
<Column
width={0}
flexGrow={2}
cell={props=>(<Cell>{rows[props.rowIndex].name}</Cell>)}
header='Name'/>
<Column
width={0}
flexGrow={2}
cell={props=>(<Cell>{rows[props.rowIndex].desc}</Cell>)}
header='Description'/>
</Table>
);
}
});
上記は機能し、両方の列をレンダリングします。
今、Column
インターフェイスを簡素化するために独自のヘルパー コンポーネントを作成しようとしています。
const EnhancedColumn = React.createClass({
render: function() {
console.log('render called');
return (
<Column
width={0}
flexGrow={2}
cell={props=>(<Cell>{rows[props.rowIndex].name}</Cell>)}
header='Name'/>
);
}
});
const App2 = React.createClass({
render: function() {
return (
<Table id='foo'
height={200}
width={400}
rowsCount={rows.length}
rowHeight={26}
headerHeight={50}>
<EnhancedColumn/>
<Column
width={0}
flexGrow={2}
cell={props=>(<Cell>{rows[props.rowIndex].desc}</Cell>)}
header='Description'/>
</Table>
);
}
});
突然、EnhancedColumn
はまったくレンダリングされません (実際には、メッセージrender is called
がコンソールに表示されないため、render メソッドは呼び出されません):
これを問題として記録しました。