In our previous post we started with creating our first react app and than we learned about some basic terminologies in react. Today we are going to focus on creating the router behaviour using react library.
Incase you want to learn about filtering in react check the github code.
Github for React Router
npm install --save react-router-dom
- Import Browser router in src/index.js (Line 6 in the below code example)
component inside (Line 8)
2) Link, this component accepts the to property which directs the app to the given path.
>Contact<Link component fully renders a proper anchor tag (a) with the appropriate href, you can expect it to behave how a normal link on the web behaves.
3) Route Component, this component is a critical piece of building an application with React Router because it’s the component which is going to decide which components are rendered based on the current URL path.