Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Can't add links to table rows in React App

I wrote React function to render table. That's how the table looks.

As a parameter it takes JSON:

{
    "id": 1,
    "firstName": "Richard",
    "lastName": "Morrison",
    "numberOfAccidents": 1
},
{
    "id": 3,
    "firstName": "Gregory",
    "lastName": "House",
    "numberOfAccidents": 5
} 

Part of Table function which render rows:

<tbody {...getTableBodyProps()}>
{rows.map((row) => {
    prepareRow(row)
    return (
        <tr {...row.getRowProps()}>
            {row.cells.map(cell => {
                return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
            })}
        </tr>
    )
})}
</tbody>

I want to add link to '/patient/$id' to each row. I tried to write something like:

return <td to={‘/patient/’ + cell.getCellProps().data.id} {...cell.getCellProps()}>{cell.render('Cell')}</td>

and

const handlerRowClick = (row) => { history.push(`/patient/${row.original.id}`); }
...
return <td onClick={() => handlerRowClick(row)} {...cell.getCellProps()}>{cell.render('Cell')}</td> 

but it doesn't work. I would like to ask for advice or links which can help me to solve my problem.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should use NavLink comopenent in react-router-dom.

import { NavLink } from "react-router-dom";

<td {...cell.getCellProps()}>
    <NavLink to={`/patient/` + cell.getCellProps().data.id}>
        {cell.render("Cell")}
    </NavLink>
</td>
about 4 years ago · Juan Pablo Isaza Report

0

If you use react-router-dom, you can redirect users on several ways.

  1. Using <Link> component (docs),
  2. Using function useHistory (docs),
  3. Using <NavLink> component (docs),
  4. Using <Redirect> component (dosc)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!