Update Profile component

In the Profile view, the FollowProfileButton should only be shown when the user views the profile of other users, so we need to modify the condition for showing Edit and Delete buttons when viewing a profile as follows:

{auth.isAuthenticated().user && auth.isAuthenticated().user._id == this.state.user._id     ? (edit and delete buttons)     : (follow button)}

In the Profile component, after the user data is successfully fetched on componentDidMount, we will check if the signed in user is already following the user in the profile or not, and set the following value to the state.

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

let following = this.checkFollow(data) this.setState({user: data, following: following}) 

To determine the value ...

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.