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

made with React and SCSS

sass/scss, react
Charlie•360
@Charlie025x
A solution to the Time tracking dashboard challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I have just completed this challenge using React.js.

First I worked on a Vanila JS solution that utilizes state and a fetch request to render cards for every category object in the data.json. However I hit a wall getting all the cards to rerender when I changed the value on the state. So I just switched to using React and after taking the time to relearn React, I got my cards rendering and rerendering perfectly on state change.

May I have tips on how to further optimized my jsx code? Or even on fixing the Vanilla JS version's branch. I'd appreciate any feedback.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Jordon Young•120
    @jordon-young
    Posted about 3 years ago

    I'm not sure if looking at my project would help. I'll try to explain what I did in plain English.

    First of all, I didn't try to keep track of state or re-render elements.

    When the page loads, my script grabs the JSON data and hands it to the timeframe button 'click' event handlers. The 'data' is in the event handler callback, so I didn't have to think about making it accessible outside of my setup script.

    Actually displaying the data depends on your HTML, IDs, and classes.

    1. Timeframe button clicked (each button's callback has its timeframe 'value')
    2. I queried the DOM for every activity-card
    3. I iterated over the activity-cards using their specific activity and timeframe to pull from the data object and set the corresponding elements' innerText

    How I grabbed the correct elements was a mix of IDs and CSS Classes. I made the ID for each activity-card the activity name, and I had an element inside each card for .hours and .previous-hours.

  • Charlie•360
    @Charlie025x
    Posted about 3 years ago

    UPDATE* I have just completed this challenge using React.js, using a map method on the data.json to render the cards. All I had to do was convert my html to jsx, impliment a few lines of code from my original js file to the React's .jsx files, and relearn how state and props work.

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 1st-party linked stylesheets, and styles within <style> tags.

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.

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