Outline
In this video, we create a Profile
component under src/components
that we'll use to display user information. Here's the finished code:
// src/components/Profile.js
import React from 'react';
import { useAuth0 } from '../react-auth0-spa';
const Profile = () => {
const { loading, user } = useAuth0();
if (loading || !user) {
return <div>Loading...</div>;
}
return (
<>
<img src={user.picture} alt="Profile Picture" />
<h2>{user.name}</h2>
<p>{user.email}</p>
<code>{JSON.stringify(user, null, 2)}</code>
</>
);
};
export default Profile;
In the next video, we'll add a route to our app so we can see this component in action.