Implementing Infinite Scroll in a mobile application

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Implementing Infinite Scroll in a mobile application
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Infinite Scroll in Mobile Application

Infinite scroll implemented in every second app and broken in roughly half of them. Duplicate requests on list end, spinner showing forever after network error, or list jumping back when adding new items — all follow from same technical mistakes.

Main Problem: Multiple onEndReached Calls

FlatList.onEndReached in React Native fires not once — it can trigger multiple times in quick scroll, on first render if content less than screen, on component height change. Protection:

const isLoadingMore = useRef(false);

const handleEndReached = useCallback(() => {
  if (isLoadingMore.current || !hasNextPage) return;
  isLoadingMore.current = true;
  fetchNextPage().finally(() => {
    isLoadingMore.current = false;
  });
}, [hasNextPage, fetchNextPage]);

useRef instead of useState because useState doesn't update between two synchronous onEndReached calls.

onEndReachedThreshold={0.3} — start loading when 30% remains to end. At 0.1 user sees spinner before data loads. At 0.5 data preloads too early, wasting traffic.

Cursor-based vs Offset Pagination

Offset-based (?page=2&limit=20) breaks with parallel new elements: page 2 shifts and user either skips items or sees duplicates. Cursor-based (?after=cursor_value) stable — each request starts exactly from last received item.

If API returns only offset — implement client-side deduplication by id:

const uniqueItems = [...existingItems, ...newItems].filter(
  (item, index, arr) => arr.findIndex(i => i.id === item.id) === index
);

On FlutterScrollController with addListener:

_scrollController.addListener(() {
  if (_scrollController.position.pixels >=
      _scrollController.position.maxScrollExtent - 200) {
    _loadMore();
  }
});

Alternative — package:infinite_scroll_pagination (pub.dev). Manages pagination state, errors and retry from box. PagingController + PagedListView — minimal boilerplate.

On Android with ComposeLazyListState.firstVisibleItemScrollOffset + derivedStateOf:

val shouldLoadMore by remember {
  derivedStateOf {
    val lastVisibleIndex = listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
    lastVisibleIndex >= items.size - 5 && !isLoading
  }
}

derivedStateOf guarantees recomposition only when shouldLoadMore truly changes, not on every scroll pixel.

Handling States

Infinite scroll requires correct handling of four states:

State UI
Initial load Skeleton list (not center spinner)
Loading next page Footer with CircularProgressIndicator
Error loading next page Footer with error text + Retry button
All data loaded Footer "No more items" or nothing

Footer added as ListFooterComponent in FlatList or via itemCount: items.length + (state != DONE ? 1 : 0) in Compose.

From practice: social app, Flutter. Feed of 1000+ posts. Complaints about duplicate posts. Turned out: fast scroll triggered _loadMore() 3–4 times in parallel before first response. Cursor didn't update — every request went with one cursor. Added bool _isLoading flag + early return — duplicates disappeared.

Scroll to Top

On new items in realtime feed, don't force jump to new posts. Show floating button "N new posts" — user decides when to scroll up. scrollToIndex(0) via listRef in RN or animateScrollTo(0) in Flutter.

What's Included

  • Infinite scroll with cursor-based or offset pagination
  • Protection from multiple requests
  • Footer: spinner / error with retry / end of list
  • Skeleton-load for first page
  • Client-side deduplication if needed
  • "New items" button for realtime feeds

Timeline

1–3 business days depending on item complexity and error handling requirements. Cost calculated individually.