Code RoomFeed appender loads wrong page
HardPrep Room Coding #2028

Feed appender loads wrong page

Code reviewNetworking & APIsConcurrencySenior–Staff~22 min

Review this React TypeScript paginated appender.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1function Feed({ topic }: { topic: string }) {
2 const [items, setItems] = useState<Post[]>([]);
3 const [page, setPage] = useState(0);
4 
5 const loadMore = async () => {
6 setPage((p) => p + 1);
7 const res = await fetch(`/api/feed?topic=${topic}&page=${page}`);
8 const data = await res.json();
9 setItems((prev) => [...prev, ...data.posts]);
10 };
11 
12 return <List items={items} onEnd={loadMore} />;
13}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.