I am trying to create a clickable table, in row manner. When the row is clicked, I would like to open a page and passing the data. Data from the row. At the moment the click works as the console prints. However, I am unable to pass the data and open the page.
Can someone help or guide me how to achieve this?
When I click the row, I can see on console the output. However, it doesn't go to the /flight-detail
and pass the data.
FlightList.js
<tbody>
{flights.map((f, i) => {
return (
<tr key={i} onClick={() => handleClick(f)}>
<td>{f.date}</td>
<td>{f.flightNumber}</td>
<td>{f.origin}</td>
<td>{f.destination}</td>
</tr>
);
})}
</tbody>
Click handler method:
function handleClick(e) {
// THIS PRINTS AND WORKS
console.log("clicked", e.flightNumber, "...", e.origin);
<Link to={{ pathname: "/flight-detail", data: e }}></Link>;
}
App.js
...
...
<Route path="/flight-detail" component={FlightDetail} />