diff --git a/package.json b/package.json index 7942e66..e409710 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "axios": "^0.18.1", "react": "^16.8.6", "react-dom": "^16.8.6", - "react-router-dom": "^5.0.0", + "react-router-dom": "^6.2.1", "react-scripts": "3.0.1" }, "scripts": { diff --git a/src/App.js b/src/App.js index 308f200..5671761 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ import React from 'react'; -import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; +import { BrowserRouter, Routes, Route } from 'react-router-dom'; import Navbar from './components/layout/Navbar'; import User from './components/users/User'; import Alert from './components/layout/Alert'; @@ -16,20 +16,20 @@ const App = () => { return ( - +
- - - - - - + + } /> + } /> + } /> + } /> +
-
+
); diff --git a/src/components/users/User.js b/src/components/users/User.js index 977e62c..8fa55b3 100644 --- a/src/components/users/User.js +++ b/src/components/users/User.js @@ -1,17 +1,18 @@ import React, { Fragment, useEffect, useContext } from 'react'; import Spinner from '../layout/Spinner'; import Repos from '../repos/Repos'; -import { Link } from 'react-router-dom'; +import { Link, useParams } from 'react-router-dom'; import GithubContext from '../../context/github/githubContext'; -const User = ({ match }) => { +const User = () => { + const params = useParams(); const githubContext = useContext(GithubContext); const { getUser, loading, user, repos, getUserRepos } = githubContext; useEffect(() => { - getUser(match.params.login); - getUserRepos(match.params.login); + getUser(params.login); + getUserRepos(params.login); // eslint-disable-next-line }, []);