What's your biggest current challenge? Have your say in Community Polls along the right column.

Blank screen in flashlist when scrolling large data and also moving upwards when select an item

Blank screen in flashlist when scrolling large data and also moving upwards when select an item

us2310
Visitor
1 0 0

When I use Flashlist then scrolling through a large list using FlashList on the web, it momentarily shows a blank screen.

 

 

 

 

 

 

 

<FlashList
   data={data}
   renderItem={getRenderItemView}
   keyExtractor={getKeyExtractor}
   estimatedItemSize={65}
   contentInsetAdjustmentBehavior="automatic"
   ListFooterComponent={renderFooter()}
/>

 

 

 

 

 

 

 

Reply 1 (1)

Entesta
Shopify Partner
80 8 20

Try implementing progressive loading instead of loading all data at once, load data in chunks as the user scrolls.

import React, { useState, useCallback } from 'react';
   import { FlashList } from '@shopify/flash-list';

   const ProgressiveLoadingList = () => {
     const [data, setData] = useState([]);
     const [isLoading, setIsLoading] = useState(false);
     const [page, setPage] = useState(1);

     const loadMoreData = useCallback(async () => {
       if (isLoading) return;
       setIsLoading(true);
       try {
         // Replace this with your actual API call
         const newData = await fetchData(page);
         setData(prevData => [...prevData, ...newData]);
         setPage(prevPage => prevPage + 1);
       } catch (error) {
         console.error('Error loading more data:', error);
       } finally {
         setIsLoading(false);
       }
     }, [isLoading, page]);

     const renderItem = ({ item }) => (
       // Your render item logic here
     );

     const renderFooter = () => {
       if (!isLoading) return null;
       return <ActivityIndicator size="large" />;
     };

     return (
       <FlashList
         data={data}
         renderItem={renderItem}
         keyExtractor={(item) => item.id.toString()}
         estimatedItemSize={100}
         onEndReached={loadMoreData}
         onEndReachedThreshold={0.5}
         ListFooterComponent={renderFooter}
       />
     );
   };

   export default ProgressiveLoadingList;
We value your feedback! Let us know if this helped by giving it a thumbs up or marking it as a solution or buy us a coffee.
Looking for Shopify experts to help you with your website? We are just one click away. Drop an email or say hi on WhatsApp to initiate a request support@entesta.com | +91 79083 21294
Entesta - Powering Your E-Commerce Journey with Shopify Expertise