Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda