How to implement React Routing
Published in
1 min readApr 21, 2020
In this article, I will be explaining how to implement routing in react app in very simple steps.
Step 1: Install react-router-dom
npm install react-router-dom
Step 2: Importing react-router-dom in our project
In the above code, we have wrapped our <App/> component with <BrowserRouter /> which enables us to use Html 5 history API.
Step 3: Implement Routing
In app.js we need to implement switch cases with various routes as shown in the above code.
Each Route component needs two mandatory props and that is the path and the component to render.
Congratulations, you have now implemented routing in your react app.