From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Display the active link

Display the active link

- [Instructor] Now we can navigate between the multiple views of our single-page application. What would be nice also is to actually display which link is active. So when you are in this location, showing which link is active based on the current pathname. So, we're going to go back to this components Navbar and find the navigation. So this is where you have all the links. And just make sure that you have, here at the top, we're going to add this hook from the react-router library, useLocation. This one returns an object. And in this object, we're going to get the information of the pathname in order to give us the current location. And here we've been using for every link the same class, CSS, in order to display an active link. So actually, let's remove this one from the second link. You're going to see the difference. And here you can see that this one is slightly faint and this one is darker. So this is to display…

Contents