React Router Example

React Router Example – In this article I will explain the React Router example in Visual Studio Code editor. VS Code is the light weight editor when we compare other editors like android studio. React is JavaScript library used for develop web application and mobile application. In this React framework developed and under maintained by Facebook company. Facebook website and android app also use reactjs language in some place to develop interface within web service API.

Angular is a competition framework for flutter. Angular also used for develop web applications and mobile applications. Its developed and maintained by Google Community. If you like to learn angular framework, then saw my YouTube complete angular tutorial video Click here to learn more about angular framework.

What is Routing

Before start the angular routing concept, first i have to explain what is router and why its used for every framework like react,angulat,ionic and more. Simply explained, its used for go on the one page (component) to another page like HTML link(a href). In router,angular,ionic we used routing concept for generate the link for moving on one component to next component. Its enabled the navigation for visit the pages.

In old versions we need to manually install the router in our react and angular project using the following command,

C:UsersvetrireactApp>npm install react-router

But in coming versions its automatically installed when we create new project in our local space. Because without router concept we cant implement dynamic project. That’s why they are default add the routing in installation.

When we initiate the routing, need must one or more components for navigate the links. So create some components in your project. Suppose if you are beginner and don’t know to create component, read the official documentation to know more about react routing.

React Router Example

Okay lets start to develop the code, here i will explain main JavaScript code and routing code for navigate the homepage. Give some name for components, after that open the component JS file and add the following below code in project,

Add Routing

Then we have to implement the routing concept for navigate the links for our react application. Just add the following below code.

Still if you are facing error on react routing example, comment below I will try to solve your queries.

Leave a Reply