React-table: How to add HyperLink or Link router in cells

Created on 21 Nov 2019  路  2Comments  路  Source: tannerlinsley/react-table

Hi Team,

Thanks for reading my comment.. I am trying to add React router on cells and this is not working.
Can you please check what i am missing...

const data = {
rows: salesusers,
columns: [
{
label: 'Name',
sort: 'asc',
ignoreRowClick: true,
render: ({ rows }) => (< Link to="/foo/${rows.id}">Edit)
},
{
label: 'Mobile',
field: 'mobile',
sort: 'asc'
}
]
};

Can you please help me to find out what i am missing. Thanks Again

Most helpful comment

You can use the Cell property to render whatever you'd like. You can also reference info.row.original if you need more data from the original row:

const columsn = [{
  accessor: 'firstName',
  Cell: ({ cell: { value }, row: { original } }) => <Link to={`users/${original.id}`}>{value}</Link>
}]

All 2 comments

render: ({ rows }) => (< Link to="/foo/${rows.id}">Edit)

Use Cell not render. ...for exact signature details check https://github.com/tannerlinsley/react-table/blob/master/docs/api.md#usetable at Cell: Function | React.Component => JSX section

You can use the Cell property to render whatever you'd like. You can also reference info.row.original if you need more data from the original row:

const columsn = [{
  accessor: 'firstName',
  Cell: ({ cell: { value }, row: { original } }) => <Link to={`users/${original.id}`}>{value}</Link>
}]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ggascoigne picture ggascoigne  路  18Comments

ivanov-v picture ivanov-v  路  16Comments

Grsmto picture Grsmto  路  100Comments

BenMGilman picture BenMGilman  路  22Comments

larrybotha picture larrybotha  路  20Comments