DEV Community

Cover image for #11 of 100DaysOfCode
Atulit Anand
Atulit Anand

Posted on

5 1

#11 of 100DaysOfCode

Eleventh Day.
Today is all about routing.

List Of Things That I Learned Today

  • How to use React Router? Just a note: React Router is a beautiful third-party library that can be used to implement lightning-fast client-side routing on our react application. It's a beauty for real. Most of all you can declare patterns to get your routes and then we can just use the useParams hook to read the route.
  • Reading routes via use params.
  • Applying a 404 page: Nothing too serious just check if you have received the data, if not return markup for 404 page.
  • Implementing client-side navigation.
  • Redirecting using the useNavigate hook.
  • Link and NavLink components
  <Link to='/nameOfTheRoute' >
    <Element you want to show/> or Text
  </Link>
Enter fullscreen mode Exit fullscreen mode

Link is just a smart cousin of anchor tag it just got to attribute instead of href plus it's smart.

  <NavLink 
    to='/nameOfTheRoute' 
    activeStyle={ObjectContainingStyles} 
  >
    <Element you want to show/> or Text
  </NavLink>
Enter fullscreen mode Exit fullscreen mode

Link is smart but so is NavLink the only additional functionally it provides as you can see is activeStyle attribute and that is quite literal.
The additional styles that a nav link gets after we click on it.
Easy.

And that's all for today.😀
Thanks for joining me, comment down below if you got any suggestions.
Have a wonderful day.🌷

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (1)

Collapse
 
icecoffee profile image
Atulit Anand

Code formatting is pretty bad I agree. I just don't know how to do it in here.
If you got any ideas or tricks please feel free to share.
Thanks

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay