Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 2 months ago

Product cart using React.js

accessibility, react
Nezer Ekunke•50
@dBillionaire-Dev
A solution to the Product list with cart challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

This is the first React-based website I built, and I'm really proud of how much I learned through the process. I designed it to mimic a simple e-commerce shopping experience, with core features like a dynamic product listing and a functional cart system that lets users add, remove, and view selected items.

One of the things I’m most proud of is that I didn’t just make a static site. I actually got to handle real React concepts like state management, props, conditional rendering, and component structure. It also taught me how to manage routing, user interactions, and organize files in a clean and scalable way.

Beyond the development part, I went through the full process of building, optimizing, and deploying the site using Vercel, which gave me a good sense of how real-world React apps go from local code to a live website.

What challenges did you encounter, and how did you overcome them?

Challenges I Encountered While building this project, I faced quite a few challenges that really helped me grow as a React developer:

Understanding State Management One of the biggest hurdles was figuring out how to manage state between different components, especially for the cart system. Making sure the cart updated in real-time whenever a product was added or removed took a lot of trial and error before I fully understood how useState and props worked together.

Component Reusability and Structure At the beginning, I wrote a lot of repeated code, and I struggled to separate layout from logic. It wasn’t until I refactored that I started thinking in terms of reusable components, which made the code cleaner and easier to maintain.

Dynamic Routing and Conditional Rendering Setting up routes and making sure the correct component loaded based on the URL was confusing at first, especially handling things like the cart display or error pages. Learning react-router-dom and how to conditionally render content based on state was a key challenge.

Deployment Issues When I deployed the site to Vercel for the first time, the images and some assets didn’t load because I was referencing paths the same way I did locally. Understanding the difference between src/assets and public/ paths in production took some research to solve.

These challenges really helped me understand how React handles data flow, component reusability, and deployment — and they pushed me to write better code and structure my projects more professionally.

What specific areas of your project would you like help with?

Clearing the image border, when items are removed directly from the cart and also whn order is confirmed.

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    markus•2,700
    @markuslewin
    Posted 2 months ago

    Should the border be displayed only when the item is in the cart? Could you remove activeItems, and instead reuse the check you wrote to toggle buttons?

    const Cart = () => {
      return (
        <img
          style={{
            border: cartItems.some((cartItem) => cartItem.id === item.id)
              ? "3px solid hsl(14, 86%, 42%)"
              : "none",
          }}
        />
      );
    };
    

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