Loading…
Loading…
Main had a simple EmployeeDirectory — just a list. A colleague sent a PR adding search, sort, and a stats section. It works, but the UI lags when you type quickly. Open the diff and find everything that runs on every render instead of useMemo.
React renders a component **every time** state or props change. Which means everything you write directly in the function body runs every time. Look for: 1. Loops over large arrays (`filter`, `map`, `reduce`). 2. Sorts. 3. `new Date()`, date parsing. 4. `new Set()`, `new Map()`, building heavy structures. 5. Functions with O(N×M) or worse. Look at the code and mark every such spot.