react-table custom cell component that references several row properties react-table custom cell component that references several row properties reactjs reactjs

react-table custom cell component that references several row properties


It turned out I needed to use cellInfo.original rather than cellInfo.row. When you provide a Cell renderer you should use cellInfo.original to get at all of your row data (especially if you aren’t showing that data as columns). The row only has what is displayed in the table.


I have had a similar problem and I have solved it as follows:

Cell: (tableInfo) => `$ {tableInfo.data [tableInfo.row.index] .dateToShow}`

where:tableInfo is an object that has among other things the following attributes: {columns: []}, data: [], comlumn: {}, row: [.], cell: {}} and dateToShow is a value that is not in the view, but exists in the data model.If you need to access data that is in the table view you can use the row object, if it is not in the table view you can access the data model using the data array.


in a column you can have:

 {     Header: "dataProperty",     accessor: "dataProperty",     Cell: ({ value, row }) => {         // here you can use value to render cell          // with value of dataProperty         // or you can access all other row data properties          // from row.original         // for example:         return row.original.id;       }    },