Menu

How To Use React Router In React JS

Hello Friends,

Today we will learn how to use React Router in React JS. React routing is used to it is allowed you to display pages and allow users to navigate easily.

Lat's to start developing the react route in detail steps.

Create React routing Steps:

Step 1: Install React Router

The first step is Install React router in the React JS. Run the fooling command using your terminal or command prompt(CMD).

npm install react-router-dom

 

Step 2: Create Router Folder and File

Now to need to Create a Router folder and File in the Out of Screen Folder.

import React, { useState, useEffect } from "react";
import { BrowserRouter as Router, Routes, Route, Navigate } from "react-router-dom";
import Path Name from "Path Screen";

function AppRoutes() {
  return (
            
       
 <Router>
          <Routes>
  
               
<Route path={'Path URl To Navigate'} element={<Path Name />} />
          <Router>
       <Routes>

         
  )
}
export default AppRoutes;

I hope this post is helpful to you. You can share this post with your friends and team. You can suggest me next topic for the post.
Thanks.
 

 

652
Search

Ads