1

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 メソッドは呼び出されません):

ここに画像の説明を入力

これを問題として記録しました。

4

0 に答える 0