Search code examples
node.jsreactjsmaterial-uimaterial-table

How to display html link inside table cell using reactjs material-table


I am using material-table of Reactjs npm package, I want display a link with url inside table cells. but it is displaying it as string. Any idea how to display link

data: [
      {
        subject: 'Announcment',
        type: 1,
        approver: 'john',
        state: 1,
        view: "<Link to="/users">cell</Link>",
      },
    ]

Solution

  • I think you should try out something like this

    import { Link } from 'react-router';
    
    const columns = [
      {
        header: '',
        id: 'links',
        render: ({ row }) => (<Link to={{ pathname: `/example/${row.id}` }}>{row.name}</Link>)
      }
    ];
    

    I didn't double-check the code so there might be some syntax errors