Profile component

The Profile component in client/user/Profile.js shows a single user's information in the view at the '/user/:userId' path, where the userId parameter represents the ID of the specific user:

This profile information can be fetched from the server only if the user is signed in, and to verify this, the component has to provide the JWT to the read fetch call, otherwise, the user should be redirected to the Sign In view.

In the Profile component definition, we first need to initialize the state with an empty user and set redirectToSignin to false.

mern-skeleton/client/user/Profile.js:

class Profile extends Component { constructor({match}) ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.