April 2020
Intermediate to advanced
716 pages
18h 55m
English
The content section will show the text of the post and the image if the post contains a photo. The code to display these details in the content section will be as follows.
mern-social/client/post/Post.js:
<CardContent className={classes.cardContent}> <Typography component="p" className={classes.text}> {props.post.text} </Typography> {props.post.photo && (<div className={classes.photo}> <img className={classes.media} src={'/api/posts/photo/'+ props.post._id}/> </div>) }</CardContent>
The image is loaded by adding the photo API to the src attribute in the img tag if the given post contains a photo. Followed by this content section is the actions section.
Read now
Unlock full access