Loading problem…
Build an Infinite Scroll Feed component in React that loads paginated content automatically as the user reaches the bottom.
hasMore is falseCreate a local dummy paginated API in your implementation (do not call external services). Use seeded items like this:
const allItems: FeedItem[] = Array.from({ length: PAGE_SIZE * MAX_PAGES }, (_, i) => ({
id: i + 1,
author: `Engineer ${((i % 7) + 1).toString()}`,
body: `Post #${i + 1}: Building resilient UI with loading, retry, and pagination.` ,
likes: 12 + ((i * 13) % 87),
}));Then expose a page-based function (for example fetchPage(page)) that returns items and hasMore.
interface FeedItem {
id: number;
author: string;
body: string;
likes: number;
}
interface PageResult {
items: FeedItem[];
hasMore: boolean;
}
type FetchPage = (page: number) => Promise<PageResult>;