This question evaluates client-side React skills including state management, asynchronous data fetching, optimistic UI updates, and deterministic sorting and deletion behavior for a blog feed.
You are building a simple Blog Posts page (React). Implement the UI and client-side logic in incremental steps.
Assume each post has at least:
id: string
authorId: string
content: string
createdAt: ISO string
likeCount: number
lastLikedAt: ISO string | null
(timestamp when this post most recently received a like;
null
if never)
Assume each user has:
id: string
name: string
textarea
and a submit button.
Replace the local JSON source with API calls:
GET /api/posts
).
authorId
(not the author name).
GET /api/users/:id
), and fetch the
current user
(e.g.,
GET /api/me
).
likeCount
descending.
likeCount
is tied, the post that was
most recently liked
(
lastLikedAt
descending) comes first.
likeCount
/
lastLikedAt
).
id
/timestamps for new local posts).