I have a table in React. The table gets data from the server. I need to do one thing when clicking on the field in the table. I have to update the information then.
My table looks like this
<div>
<MDBTable bordered borderColor="primary">
<MDBTableBody>
{tableRows.map((row) => (
<tr
key={row.id}
className={selectedRow === row.id ? "selected" : ""}
onClick={() => handleRowClick(row.id)}
>
<th scope="row">{row.id}</th>
<td>{row.name}</td>
</tr>
))}
</MDBTableBody>
</MDBTable>
</div>
How to do that? I don’t need a Edit button. I just need to edit when I click in the field.
2
Answers
I solve my problem using Ant design library this code it's work when click to the input field I can Update data
Get an input field:
Initially, keep it disabled and change it on the onClick event.