Interactive comment section with React and useState
Design comparison
Solution retrospective
This challenge defeated me :), I did as many interactions as I could but I obviously dont know react well enough to pull it off :). I will come back to this challenge when I will learn a bit more about state and hooks. I will appreciate any tips on how to fix deleteReply function so that it only removes deeply nested reply instead of overwriting whole "comments" part of my DUMMY_DATA. :) cheers
Community feedback
- @seanred360Posted over 2 years ago
I recommend you use object destructuring in ALL of your components, you have a lot of duplicate variable names and collisions. I was very hard for me to understand what was going on. Pretty easy fix though. Check my pull request on Github for details on how to do that. Good job so far, you seem to grasp Javascript pretty well. You just need to learn the best practices for React.
Marked as helpful0@JanWu100Posted over 2 years ago@seanred360 Thank You very much for help, that was also first time I had anyone contributed to my code on github so I could learn a bit about that aswell. And also thank You for the nice words, I really needed that after not being able to fix all bugs with that challenge :) appreciate that
0@seanred360Posted over 2 years ago@JanWu100 I am also doing Github for practice lol. It's really hard to get started collaborating on Github so I figured I would just find other beginners that also want to break into it.
You have a good grasp on programming for sure, you just need to know "The React way" of thinking, and how people typically structure their apps.
0 - @seanred360Posted over 2 years ago
You no not need to fix your handling of deleteReply. For this small project what you did is fine. If the goal was to create a massive scalable database like Facebook has you would normalize the data, which means you would make all your data 1 level deep. So you would have a collection called "comments", that is an array of comment objects with the id, content, author, and the unique IDs of all the replies, but not their content. You would have another collection called 'replies' that is an array of reply objects with author, content, and the unique ID of the comment that you are replying to. You would have a collection called "users" that only an array of user objects with a username, photo, date joined etc. The reason you have everything spread out is because it would not be possible for 1 user to download every post and user's data on the entire database of Facebook on load. You have to put everything in small separated collections so you can only grab what you need. So when you want to fetch your replies you look at the replies IDs array in your comment and fetch only the replies from the replies collection that have the ID contained in your comment.
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord