project_mern_memories
project_mern_memories copied to clipboard
TypeError: Cannot read property 'find' of undefined
After updating the post the below error message gets displayed immediately even though the update was successful. The updated post can be seen once the page is refreshed. Version: Part_6
The error: C:/Users/project_mern_memories-PART_6/client/src/components/Posts/Post/Post.js:22
19 | const classes = useStyles(); 20 | 21 | const userId = user?.result.googleId || user?.result?._id;
22 | const hasLikedPost = post.likes.find((like) => like === userId); | ^ 23 | 24 | const handleLike = async () => { 25 | dispatch(likePost(post._id));
Could someone please help me with this issue?
Hey , I did this : const hasLikedPost = likes.find((like) => like === userId);
It worked @VibhuGautam . Thank you so much.
Thank you! this works
Hey , I did this : const hasLikedPost = likes.find((like) => like === userId);