Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

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

#react
Robin Del Mundoβ€’ 50

@Robincredible

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

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?

Community feedback

P

@christopher-adolphe

Posted

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 an onClick props on the div className='ratings-main-container' onClick={this.handleClick} > while this.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

1

Robin Del Mundoβ€’ 50

@Robincredible

Posted

@christopher-adolphe Hello Christopher! Thank you for the kind words!

My first choice was actually radio buttons! But I found them hard to style and customize so I just went with this. I forgot about <input type="hidden"> as well until I researched some solutions just to have an input inside the <form>!

Thanks for this! Splitting parts of the UI into components was actually a real problem down the line that I was so confused if I was doing it right. Thanks for sharing your insights and I'll definitely make it simpler next time!

For the <RatingsContainer> component, this was something that I actually forgot to remove when I was trying to do a feature that resets the selected rating if you clicked outside of the numbers/submit button. This was one of the problems that came up which definitely made me rethink why I made so many components πŸ˜…This is why you would see a React.createRef on the <Rating> component, it was just a quick fix for my bad code structure.

For using React, yep! It wasn't necessary of course, I just wanted to see if I could accomplish this challenge after learning React on freecodecamp. Thanks for the tip on separating components into files! I'll definitely be doing that on a bigger project!

To be honest, the freecodecamp short course on react used almost exclusively class-based components! It was probably outdated in that regard because I was also able to research functional components, I just wasn't able to use them here.

Thank you for sharing with me your experiences, insights and thoughts! This was really helpful and I will be using a lot of these new learnings in future projects!

Thanks and good luck on your learning path as well!

0
P

@christopher-adolphe

Posted

Hi @Robincredible,

I'm happy to help and glad you see that the feedback was useful.

In my opinion is it a good thing to know class-based components because you never know some day you might have to work on an old project which uses that. But definitely, consider learning functional components and hooks as well.

Best regards.

Marked as helpful

1
Shuaibβ€’ 640

@JustShuaib

Posted

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

1

Robin Del Mundoβ€’ 50

@Robincredible

Posted

@JustShuaib This was very helpful! I overlooked the size and I considered it upon doing revisions! Thanks!

0
Prabhash Ranjanβ€’ 2,540

@besttlookk

Posted

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

1

Robin Del Mundoβ€’ 50

@Robincredible

Posted

@besttlookk Thanks for the feedback! I considered both when I made the revisions! Thanks!

1

Please log in to post a comment

Log in with GitHub
Discord logo

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