React, Javascript, HTML, CSS, VS Code/Sublime Text, Bounce JS

Solution retrospective
Hello! This is my first time using react so this project took a while even though it was very simple! I had to solve some quirks in react that I hadn't normally dealt with on vanilla JS, like passing props and managing state properly. I quickly realized that you really have to deal with structure when using react because of how it's designed.
Feedback is very welcome as I am also a beginner! And I would very much like to learn from more experienced individuals in here about the best practices in frontend engineering!
Questions for the community:
- When you built the project, what aspects of it did you find difflicult?
- What tools did you use?
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@christopher-adolphe
Hi @Robincredible,
You did a great job for this challenge. 👍 I really like the subtle animation when a rating is selected and also the notification appears. I also like your approach to get the selected value via an
<input type="hidden">
element. It's been while since I have used the<input type="hidden">
and I almost forgot about it until I saw your code. 😅 I would have used<input type="radio">
but this is also a nice alternative. I tried to answer your questions below.- React (as well as Angular, Vue, etc.) is component-based and at the beginning, it can be difficult to determine what parts of the design should be a component on its own or not. Splitting every single part of the design into individual components can easily complicate things like managing state and events. I've set myself a rule where as soon as I see that things are getting too complicated, I take a few steps back and take a few minutes to think of simpler alternatives. For example if I was to tackle this challenge, I would have most probably created only 2 components; a generic
<Card />
component and a<RatingForm />
component. The end result would have looked like this:
<div className="App"> <div className="container"> <Card> <RatingForm /> </Card> </div> </div>
If you wish to make the
<RatingForm />
component more reusable, you could have it accept props for the title and the text like<RatingForm title="Some title" text="Some text" />
. In short, more components does not always equal better reusability. Just keep things simple.- It is also a good practice to separate components in individual files as it promotes separation of concerns, better readability and eases maintenance as your app grows. I understand this is a small project but you can start right now to build up the good habits. 😉
- In the
RatingsContainer
component, I noticed there is anonClick
props on thediv className='ratings-main-container' onClick={this.handleClick} >
whilethis.handleClick
is not set. Why is that ? 🤔 - Regarding the tools to use, I think it's just a matter of preference. For simple challenges, I tend to use just HTML, CSS and JS and as the complexity rises, I could use any of React, Angular or Vue. I just see these challenges as an opportunity to become more familiar with those tools.
I was also surprised to see that you have used class-based component, this is less common nowadays.
I am also new to React and I've tried to share with you what I've learnt so far. I hope this helps.
Keep it up.
Marked as helpful - React (as well as Angular, Vue, etc.) is component-based and at the beginning, it can be difficult to determine what parts of the design should be a component on its own or not. Splitting every single part of the design into individual components can easily complicate things like managing state and events. I've set myself a rule where as soon as I see that things are getting too complicated, I take a few steps back and take a few minutes to think of simpler alternatives. For example if I was to tackle this challenge, I would have most probably created only 2 components; a generic
- @JustShuaib
Hi Robin. The card seems quite big on a desktop. Consider reducing the size a bit? The animation & bounce effect also feels nice! 😊
Then you asked some questions:
- When I worked on mine, the part where I had issue was the effect on the list. Removing the
active
color from a button when another button is selected. - I actually used vanilla JS for the project 😀. I think I used SASS for the styling.
Happy coding!
Marked as helpful - When I worked on mine, the part where I had issue was the effect on the list. Removing the
- @besttlookk
Hi,
- Give appropriate tittle
- Consider scenario when user submit without giving a rating.
I liked the bounce effect
Nice work overall
Good luck
Happy Coding
Marked as helpful
Join 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