Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

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

react
Robin Del Mundo•50
@Robincredible
A solution to the Interactive rating component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

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?
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Christopher Adolphe•620
    @christopher-adolphe
    Posted over 3 years ago

    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
  • Shuaib•640
    @JustShuaib
    Posted over 3 years ago

    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
  • Prabhash Ranjan•2,540
    @besttlookk
    Posted over 3 years ago

    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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub