Salesforce Decode
Salesforcedecode
Back to questions
LWCAdvancedinfinite-scrollpaginationwire

Implement infinite scroll and lazy loading with wire adapters

Real World Scenario

Activity timeline LWC must load older tasks on scroll without reloading entire 500-item list.

Expected Answer

• Imperative Apex pagination with pageToken or offset cursor • Append results to tracked array on scroll intersection observer • Guard against duplicate fetch while prior page loading • Empty and end-of-list states with clear UX • Reset pagination when parent recordId changes • Consider getRelatedListRecords limits vs Apex for very large related lists • Debounce scroll handler preventing request storms

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. Imperative Apex pagination with pageToken or offset cursor. Append results to tracked array on scroll intersection observer. Pick based on your integration pattern and team capability. Cursor pagination beats offset at scale—design Apex API with lastId parameter. Optimize for scale and operational observability.

Architect Perspective

Cursor pagination beats offset at scale—design Apex API with lastId parameter.