Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-bootstrap nav.link routing

I am working on a project. I have navbar and nav.links on it. such as home, price and features.

I would like to page routing when I click it. Here is my codes about it. I did it usual routing style but it doesn't work.

<LinkContainer>
     <Nav.Link to="/price" >Price</Nav.Link>
</LinkContainer>

and my routing definations in app.js;

<Route path ="/price" exact component={Price}></Route>

I create and import price.js and also import them.

I can succesfully use routing on my buttons but nav.links doesn't work. Any idea?

*Btw it was orginally like this <Nav.Link href="#price" >Price</Nav.Link> Actually idk what is href for?So, I erased it and add "to"


1 Answers

This code works for me:

<Nav.Link as={Link} to="/home" >Home</Nav.Link>

like image 146
Saif Avatar answered Feb 02 '26 07:02

Saif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!