Monday, November 14, 2016

React Router (react-router-dom)

To implement routing in a ReactJS application...


  • You need to install react-router-dom
  • Use the components BrowserRouter, Route, Switch, Link from react-router-dom module.
  • Define the routes and wrap them in BrowserRouter
  • Define the links
  • and you are ready to go. 

npm i react-router-dom --save











Recently stumbled across this blog which is an interesting read on react-router-dom:
https://blog.pshrmn.com/simple-react-router-v4-tutorial/



Found this tutorial loaded on GitHub which gives a simple beginning and escalates to advanced level.

I liked the first line in the tutorial..."At its heart React Router is a component, and its not going to display anything until you configure a route". Read and practice the tutorial...

https://github.com/reactjs/react-router-tutorial/tree/master/lessons/02-rendering-a-route

Another good example:

No comments:

Post a Comment