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

React Router + tailwind

react, tailwind-css
P
Feng•380
@niuguy
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?
  1. Solved the image import problem using
  const importAll = (r: Record<string, { default: string }>) => {
    const imageMap: Record<string, string> = {};
    Object.entries(r).forEach(([key, value]) => {
      imageMap[key.replace('../assets/images/', '')] = value.default;
    });
    return imageMap;
  };
  const imageImports = importAll(import.meta.glob('../assets/images/*.jpg', { eager: true }));
  1. Refactored the codebase using context to handle shopping cart state
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Feng's solution.

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