react-table 7 custom cell says data undefined

Viewed 356

In version 6 this used to work, some of the rows doesn't have price, but original should be pointing to the row.

        {
            accessor : 'price',
            Header: () => <b>Price</b>,
            style: { 'whiteSpace': 'unset' },
            Cell: ({original}) => original.price && <div className="full-center">{original.price}</div>,
        },

But after upgraded to version 7, now I am getting LineMatchingPage.js:121 Uncaught TypeError: Cannot read property 'price' of undefined

1 Answers

It seems there is a subtle change in version 7, that accessor returns the value gets fed into Cell, so in this case, in version 7, original does not represent the row anymore, but the value of the accessor which is the value of the price

    {
        accessor : 'price',
        Header: () => <b>Price</b>,
        style: { 'whiteSpace': 'unset' },
        Cell: ({price}) => price && <div className="full-center">{price}</div>,
    },
Related