Review
Live-filter products as the user types
Adds a polling refresh so the product list stays in sync while the user types a filter query.
ReactTier 3frontendbugs
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
components/ProductList.tsx+6-0
| 22 | 22 | const [query, setQuery] = useState(""); | |
| 23 | 23 | const [results, setResults] = useState<Product[]>([]); | |
| 24 | 24 | ||
| 25 | + | useEffect(() => { | |
| 26 | + | const id = setInterval(() => { | |
| 27 | + | setResults(filterProducts(products, query)); | |
| 28 | + | }, 1000); | |
| 29 | + | return () => clearInterval(id); | |
| 30 | + | }, []); |