T
TanStack3y ago
like-gold

Making a cell to be a react-router link

Hello, is there a way to convert a cell into a clickable react-router link within the columns definitions? For example, I currently have this:
export const productTableColumns: ColumnDef<IProduct>[] = [
{
header: "Product code",
accessorKey: "productId",
cell: (info) => info.getValue(),
id: "productId",
}

]
export const productTableColumns: ColumnDef<IProduct>[] = [
{
header: "Product code",
accessorKey: "productId",
cell: (info) => info.getValue(),
id: "productId",
}

]
and would like to convert it into a link Thank you!
1 Reply
extended-salmon
extended-salmon3y ago
the function cell: (info) => is what renders the contents of cell. If you write it like this, it will be a link cell: (info) => <Link to="/">{info.getValue()}</Link>

Did you find this page helpful?