Created
August 9, 2021 06:13
-
-
Save percybolmer/5dada9bab9af38b88dd1354d674465e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useParams, useLocation } from "react-router-dom"; | |
import React from 'react'; | |
const Profile = () => { | |
// Use the useParams hook to get the username from the URL | |
// username has to be applied as a named parameter in the route | |
let { username } = useParams(); | |
// useLocation hook is used to grab the state from the input to object | |
// You can grab each field in the object by using the same name as the variable name | |
let { pathname } = useLocation(); | |
let { state } = useLocation(); | |
return ( | |
<div> | |
<h1>{username} Profile</h1> | |
<p> Registered on:{state.registrationdate} </p> | |
<p> Visiting: {pathname}</p> | |
</div> | |
) | |
} | |
export default Profile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment