Skip to content

3D-Dev/React-router-v6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React-Router-V6 & useNavigate & BrowserRouter & Axios

Installing

npm install

add the following import statement:

import { BrowserRouter,Route,Routes } from 'react-router-dom';

<Route path="/" element={<Users />} />
<Route path="/detail/:id" exact element={<UserDetail />} />

implemented the module of geting *json data from url using axios

  const fetchData = async () => {
    let response = await axios.get(
      "https://jsonplaceholder.typicode.com/posts/1/comments"
    );
    if (response.status === 200) {
      setUsers(response.data);
    }
  };