Using anchor tag with React router and avoid page reload

Viewed 784

We show a grid to users with product info. The first column is supposed to show a link to take the user to another route that displays product details. The grid component we use, accepts a template for cell. So we can provide something like this:

<a href='/product-details/{row.productId}'>{row.productName}</a>

This renders fine and the link is fine too. However, when the product name is clicked it reloads the page. We cannot use Link tag here.

Is there a way to form a link manually using the anchor tag - how the react-router's Link element creates links?

Please note that we want to use BrowserRouter. If we use HashRouter, we can form the links with /#/ and the page doesn't reload. However, we want to avoid using HashRouter.

0 Answers
Related