Proactively choose the right state management pattern: derived state, URL state, server state, local state, lifted state, Context, or external store. Always apply without being asked.
84
76%
Does it follow best practices?
Impact
97%
1.16xAverage score across 5 eval scenarios
Passed
No known issues
Build a small online store in React with TypeScript. The store has a product catalog and a shopping cart that persists across pages.
Product Catalog:
/api/products which returns { products: Product[] } where each Product has id: string, name: string, price: number, category: string, image: string, and inStock: boolean.Shopping Cart:
POST /api/cart to persist server-side, but the UI should update immediately without waiting.Pages (use React Router):
/products -- the product catalog with search and filters/products/:id -- a product detail page (fetches from /api/products/:id)/cart -- a full cart pageProduce TypeScript/TSX files in a src/ directory:
src/types.ts -- TypeScript type definitionssrc/hooks/useProducts.ts -- hook to fetch product datasrc/hooks/useProduct.ts -- hook to fetch a single productsrc/context/CartContext.tsx -- cart state shared across the appsrc/components/Header.tsx -- header with cart icon and countsrc/components/ProductCatalog.tsx -- the catalog page with search/filtersrc/components/ProductCard.tsx -- individual product cardsrc/components/ProductDetail.tsx -- product detail pagesrc/components/CartDrawer.tsx -- the slide-out cart panelsrc/components/CartPage.tsx -- the full cart pagesrc/App.tsx -- app with routingThe code does not need to run against a real server. Do not include test files or build configuration.