Skip to solution
hardMachine Coding

Build an E-commerce Product Filter grid

1.2k views
01

Understand the problem

Build a product grid with category, price and rating filters plus sort.

ReactFiltersData
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Solve in

Building an E-commerce Product Filter Grid in React

Mental model: Keep the product list immutable. Filters (selected categories, max price, sort) are state; the shown products are derived by chaining filter → sort. Each filter narrows the set; deriving on render keeps the grid always consistent with the contr

Solution ready — 2 min read

Classified // press E to declassify

04

React solution

Complete solutionRun Playground
import React from 'react';
import ProductFilter from './src/ProductFilter';

const products = [
  { id: 1, name: 'Headphones', category: 'Audio', price: 120 },
  { id: 2, name: 'Speaker', category: 'Audio', price: 80 },
  { id: 3, name: 'Keyboard', category: 'Computers', price: 60 },
  { id: 4, name: 'Mouse', category: 'Computers', price: 30 },
  { id: 5, name: 'Monitor', category: 'Computers', price: 220 },
  { id: 6, name: 'Camera', category: 'Photo', price: 450 },
  { id: 7, name: 'Tripod', category: 'Photo', price: 40 },
  { id: 8, name: 'Earbuds', category: 'Audio', price: 95 },
];

export default function App() {
  return (
    <div style={{ fontFamily: 'sans-serif', padding: 20 }}>
      <h1>Product Filter Demo</h1>
      <ProductFilter products={products} />
    </div>
  );
}
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 64 of 87 decoded in the Frontend Machine Coding track. One more won't hurt.

Back to track