JavaScriptJavaScript FrameworksReact

Creating Routes in ReactJS Using React Router Dom 5

In this video, we’ll install React Router Dom 5 and create routes for our app.

Install React Router Dom 5

Install the react router dom version 5 using the command terminal.

npm install react-router-dom@5

index.js

Import and wrap the root component with the BrowserRouter.

JSX

App.js Component

In the App.js module, import Switch and Route from react-router-dom then create route paths to each component. Below is an example of a route to the /flights/:id url.

JSX
Verified by MonsterInsights