First run npm i react-router-dom
create pages folder in src folder
here create files in pages like add.jsx, update.jsx, delete,jsx
in every file defined as follows: example of add paged
import React from ‘react’
const add = () => {
return (
<div>
Add
</div>
)
}
export default add
now go to App.js and import these files
import Add from “./pages/add”;
import Test from “./pages/test”;
Now you can make link or url
import {
createBrowserRouter,
RouterProvider,
Routes,
Route,
Link,
BrowserRouter,
} from “react-router-dom”;
import Add from “./pages/add”;
import Test from “./pages/test”;
import Update from “./pages/Update”;
import Delete from “./pages/Delete”;
function App() {
return (
<div className=”App”>
<BrowserRouter>
<Routes>
<Route path=”/” element={<Test />} />
<Route path=”/add” element={<Add />} />
<Route path=”/update” element={<Update />} />
<Route path=”/delete” element={<Delete />} />
</Routes>
</BrowserRouter>
</div>
);
}
export default App;