Giter Site home page Giter Site logo

marcocesarato / react-native-big-list Goto Github PK

View Code? Open in Web Editor NEW
519.0 3.0 40.0 12.78 MB

This is a high performance list view for React Native with support for complex layouts using a similar FlatList usage to make easy the replacement. This list implementation for big list rendering on React Native works with a recycler focused on performance and memory usage and so it permits processing thousands items on the list.

Home Page: https://marcocesarato.github.io/react-native-big-list-docs/

License: Apache License 2.0

JavaScript 100.00%
list fast big large massive react-native react web expo android ios data flatlist react-native-big-list sticky-headers javascript js performance memory

react-native-big-list's Introduction

React Native Big List

If this project has helped you out, please support us with a star 🌟


NPM version js-prittier-style Compatibility

Documentation

πŸ“˜ Description

What is this?

This is a high performance list view for React Native with support for complex layouts using a similar FlatList usage to make easy the replacement. This list implementation for big list rendering on React Native works with a recycler focused on performance and memory usage and so it permits processing thousands items on the list.

You can also try it on the published web app: Demo

Why another list library?

React Native's FlatList is great but when it comes to big lists it has some flaws because of its item caching. Exists some alternatives like react-native-largelist and recyclerlistview but both have some issues.

The react-native-largelist isn't compatible with web and Expo, has native code that sometimes need to be readjusted and maintained, have a weird list item recycles (because it never has blank items), need data restructure and have some issues when trying to process a lot of data (eg: 100,000 items) because it would freeze the CPU.

The recyclerlistview is performant but suffers from an empty frame on mount, weird scroll positions when trying to scroll to an element on mount, and the implementation of sticky headers conflicts with Animated.

How it works?

Recycler makes it easy to efficiently display large sets of data. You supply the data and define how each item looks, and the recycler library dynamically creates the elements when they're needed. As the name implies, the recycler recycles those individual elements. When an item scrolls off the screen, the recycler doesn't destroy its view. Instead, the recycler reuses the view for new items that have scrolled onscreen. This reuse vastly improves performance, improving your app's responsiveness and reducing power consumption.

When list can't render your items fast enough the non-rendered components will appear as blank space.

This library is fully JS native, so it's compatible with all available platforms: Android, iOS, Windows, MacOS, Web and Expo.

πŸ“– Install

Install the library from npm or yarn just running one of the following command lines:

npm yarn
npm install react-native-big-list --save yarn add react-native-big-list

πŸ’» Usage

Read also How to migrate from FlatList

Basic example:

import BigList from "react-native-big-list";
// ...
const MyExample = ({ data }) => {
  const renderItem = ({ item, index }) => <MyListItem item={item} />;
  return <BigList data={data} renderItem={renderItem} itemHeight={50} />;
};

For more examples check the example directory the list directory or check the Documentation

🎨 Screenshots

BigList vs FlatList Section List

⚑️ Example

Snippets

Expo

Clone or download repo and after:

cd Example
yarn install # or npm install
expo start

Open Expo Client on your device. Use it to scan the QR code printed by expo start. You may have to wait a minute while your project bundles and loads for the first time.

You can also try it on the published web app: Demo

πŸ’‘ Props and Methods

The list has the same props of the ScrollView in addition to its specific Props and Methods.

πŸ€” How to contribute

Have an idea? Found a bug? Please raise to ISSUES or PULL REQUEST. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.


react-native-big-list's People

Contributors

aminerol avatar dependabot[bot] avatar doomsower avatar hoangvvo avatar hyoper avatar imgbotapp avatar kewde avatar labtorie avatar larsmunkholm avatar marcocesarato avatar marxvn avatar mvayngrib avatar sabymike avatar themichaellai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-big-list's Issues

TypeScript type declarations missing for the methods

Hello,

Thanks for this library.

FYI, the .d.ts file doesn't includes the type declarations for the custom methods as well as the FlatList methods.

const listRef = useRef<BigList>(null);

// This line return a TypeScript error:
// TS2339: Property 'scrollToSection' does not exist on type 'BigList '.
listRef.current?.scrollToSection({
    section: 0,
    animated: true,
});

<BigList ref={listRef} ... />

The temporary solution (but quiet ugly) is to set the comment line // @ts-ignore before the call of the methods.

Thanks

License

Hey,

Any chance switching license from GPL to more friendly MIT or Apache 2

Best regards

Every list Item is rendered multiple times

If we wrap the BigList component with SafeAreaProvider or using react-navigation every list Item is rendered multiple times. Please check this snack https://snack.expo.dev/@mydesweb/safeareaissue

This is bad since it is a negative performance impact.

  1. Open the code from your device
  2. Check the console logs
  3. Shake & Reload button from expo app or remove the app from background and open again
  4. You will see unexpected multiple Item renders

Can anybody explain why this is happening?
Screenshot 2021-12-19 at 11 42 30

Is there a limit?

Greetings

Thank you, for create this component. I just wanted to ask if a million items can be displayed? In this scenario it would work for Android as well as for iOS?

Inverted Prop Problem

Hey! How do I make the section footer sticky?

I need this because using an inverted list my section header becomes a footer and, accordingly, using the stickySectionHeadersEnabled property does not work for me.

this is the same as Flaslist.

this package has no performance improvements. there are still white blank spaces. this is also a problem in react Flatlist if we provide the ```
getItemLayout={(data, index) => (
{length: 54, offset: 54 * index, index}
)}

no other effect I have seen. I am rendering about 2000 contacts. 

Here is the example and source code. 

`import React,{useEffect} from 'react';
import {View, Text, StyleSheet,TouchableOpacity,Image, StatusBar,FlatList,} from 'react-native';
// import {useSelector, useDispatch} from 'react-redux';
// import {getContacts} from '../actions/getcontacts';
import faker from 'faker'
import BigList from "react-native-big-list";
faker.seed(10);
const DATA = [...Array(2000).keys()].map((_, i) => {
    return {
        key: faker.datatype.number,
        image: `https://randomuser.me/api/portraits/${faker.helpers.randomize(['women', 'men'])}/${faker.datatype.number(60)}.jpg`,
        displayName: faker.name.findName(),
        jobTitle: faker.name.jobTitle(),
        email: faker.internet.email(),
        contact:faker.phone.phoneNumberFormat()
        
    };
});
const Item = ({ displayName,image,jobTitle,contact }) => (
  <TouchableOpacity style={styles.item}>
   
      <Image source={{uri:image}} style={{height:60,width:60,borderRadius:60,alignSelf:"center", resizeMode:"center"}} />
    
    <View style={{marginLeft:10,}}>
      <Text>{displayName}</Text>
      <Text>{contact}</Text>
    </View>
    <View>

    </View>
  </TouchableOpacity>
);

const PlaceholderComponent = () => (
  <TouchableOpacity style={styles.item}>
    <Image source={{uri:`https://randomuser.me/api/portraits/${faker.helpers.randomize(['women', 'men'])}/${faker.datatype.number(60)}.jpg`}} style={{height:60,width:60,borderRadius:60,alignSelf:"center", resizeMode:"center"}} />
    <View style={{marginLeft:10,}}>
      <Text>Loading</Text>
      <Text>Please Wait</Text>
    </View>
    <View>
    </View>
  </TouchableOpacity>
)


const Movies = () => {
 
  // const {contacts} = useSelector(state => state.ContactsReducer);
  // const dispatch = useDispatch();
  // const fetchContacts = () => dispatch(getContacts());
  
  
  // useEffect(() => {
  //   fetchContacts();
  // }, []);
  
  const renderItem = ({ item }) => (
    <Item 
      displayName={item.displayName} 
      image={item.image}
      jobTitle={item.jobTitle}
      contact={item.contact}      
    />
  );

  
  return (
    <View style={styles.container}>
     <BigList
        data={DATA.sort((a,b) => a.displayName > b.displayName)}
        itemHeight={96}
        renderItem={renderItem}
        placeholder={true}
        legacyImplementation={true}
        horizontal={false}
        windowSize={250}
        removeClippedSubviews={true}
        initialNumToRender={100}
        updateCellsBatchingPeriod={30}
        numColumns={1}
        onEndReachedThreshold={0.7}
        refreshing={true}
        maxToRenderPerBatch={120}
        placeholderComponent={PlaceholderComponent}
        keyExtractor={item => `${item.key.toString()}${item.displayName}${item.email}`}
      />
    </View>
  );
};
const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: StatusBar.currentHeight || 0,
  },
  item: {
    backgroundColor: '#f9c2ff',
    paddingHorizontal: 20,
    paddingVertical:10,
    marginVertical: 8,
    height:80,
    alignItems:"center",
    borderRadius:10,
    flexDirection:"row",
    marginHorizontal: 16,
  },
  title: {
    fontSize: 32,
  },
});

export default Movies;`

scrollTo functions are not working

There seems to be an issue with the scroll methods. The scrollToPosition of BigListProcessor requires a valid value for numColumns otherwise the scrollTop value results in NaN and no scroll operation is performed. The BigList component needs to make sure it is passing the numColumns prop to the processor to prevent this error.

Cannot use BigList, import error.


None of these files exist:
  * node_modules/react-native-big-list/lib/BigList(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules/react-native-big-list/lib/BigList/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
> 1 | import BigList from "./BigList";
    |                      ^
  2 |
  3 | export default BigList;
  4 |
    at ModuleResolver.resolveDependency (/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
    at DependencyGraph.resolveDependency (/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
    at Object.resolve (/node_modules/metro/src/lib/transformHelpers.js:317:42)
    at resolve (/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
    at /node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
    at /node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)```

Possibility to pass in custom ScrollView component

Would it be possible to have a prop for a "CustomScrollView" (https://github.com/Flipkart/recyclerlistview calls it externalScrollView)? My use case is to create a draggable list which uses react-native-gesture-handler. However, it only works if I use the ScrollView export from react-native-gesture-handler.

It is a small change so I can submit a PR too if it is okay too.

import { ScrollView } from "react-native-gesture-handler";

<BigList CustomScrollView={ScrollView} />

issue with ScrollViewComponent prop

hi , thank you for this great package. based on the comment at #137 (comment) I tried to pass reanimated scrollview to BigList but scrolling functionality stops working.

import { useValue, onScrollEvent } from 'react-native-redash';
import Animated from 'react-native-reanimated';

const y = useValue(0);
const onScroll = onScrollEvent({y});
const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);

< BigList ScrollViewComponent={AnimatedScrollView} {...{onScroll}} .... />

onMomentumScrollEnd not firing

const onMomentumScrollEnd = useCallback((ev) => {
       const index = Math.floor(
           ev.nativeEvent.contentOffset.x.toFixed(0) / width.toFixed(0)
       )
       scrollToActiveIndex(index)
       // setActiveIndex(index)
   }, [])

             <BigList
               ref={bigListRef}
               data={image}
               renderItem={render}
               onMomentumScrollEnd={onMomentumScrollEnd}
               onScrollEndDrag={handleScroll}
               initialScrollIndex={scrollIndex}
               onScrollToIndexFailed={scrollFailed}
               itemHeight={rowHeightAdjusted}
               getItemLayout={layOut}
               alwaysBounceVertical={false}
               bounces={false}
               scrollEventThrottle={16}
               style={{
                   marginTop: insets.top + 40,
                   marginBottom: insets.bottom + 70 + 30,
               }}
               // carousel props
               pagingEnabled
               showsHorizontalScrollIndicator={false}
               horizontal
           />

Hey guys I cant get onMomentumScrollEnd to fire, if this prop supported?

Layout trouble with images/videos

Hi everyone,

I just tried the package. Really impressive ! The performance is here. But... as soon as you introduce an image or a video, there's a layout problem. Maybe it should be better if the item height could be set to "auto" (for exemple).
Or maybe I missed something. I would like to know if anybody else has the same issue and how it may be fixed...

Thanks a lot for any information

Cant make the list horizontal, is this prop not available ?

<BigList
                ref={bigListRef}
                data={image}
                renderItem={render}
                onMomentumScrollEnd={onMomentumScrollEnd}
                onScrollEndDrag={handleScroll}
                initialScrollIndex={scrollIndex}
                onScrollToIndexFailed={scrollFailed}
                itemHeight={rowHeightAdjusted}
                getItemLayout={layOut}
                alwaysBounceVertical={false}
                bounces={false}
                scrollEventThrottle={16}
                style={{
                    marginTop: insets.top + 40,
                    marginBottom: insets.bottom + 70 + 30,
                }}
                // carousel props
                pagingEnabled
                showsHorizontalScrollIndicator={false}
                horizontal
            />

Hey guys,
Is it not possible to make the list horizontal? i'm not sure why its not its not working with the horizontal prop implemented. Am I missing something ?

Blank items on fast scroll

Hi. Currently with the BigList, when scrolling fast on an actual device the items appear as blanks for some time until they get their content. I see that no re-renders are happening to the screen so it must be the internal implementation of the list.

Can something be done about it?

Warning about potential memory leak when placeholder is true

When "placeholder" attribute is true, and after having scrolled forward (the placeholder image was rendered), and then scrolling back to the beginning of the list, the following warning is shown on the web version:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. at http://localhost:19006/static/js/bundle.js:127712:34 at div at http://localhost:19006/static/js/bundle.js:134488:25 at AnimatedComponent (http://localhost:19006/static/js/bundle.js:141995:37) at AnimatedComponentWrapper at BigListPlaceholder (http://localhost:19006/static/js/bundle.js:74833:24)

onViewableItemsChanged problem

If itemHeight passed as a function, onViewableItemsChanged stops working onScroll;
Example:
const _itemHeight = useCallback( (_, i) => { const post = postStore.posts[i]; if (post?.media?.imageSizes?.compressed) { const {imgHeight} = getImageRatio( post.media.imageSizes.compressed.width, post.media.imageSizes.compressed.height, LIST_IMAGE.WIDTH, LIST_IMAGE.MAX_HEIGHT, ); return imgHeight + 220; } return ITEM_HEIGHT; }, [postStore.posts], );

Unable to test component under Detox

Hello guys, please i realy need your help, Detox is not able to reach the UIScrollView component, i've already set up the right Accessibility Props but i'm receiving this message:

Test Failed: View β€œ<RCTView: 0x133547f00>” is not an instance of β€œUIScrollView”

Would you please help me through this please?

[Android] In some lists when using sections for data, while scrolling BigList doesnt render any item.

This is probably a very corner case. This issue happens only in Android.

  • It doesn't happen randomly at different spots everytime I open the same list. It happens at the same spot of the list everytime.

  • In another list it will happen at another index.

  • In other lists it doesn't happen at all.

  • It happens with 2 columns not with 1

  • It happens when I use sections but dont use section headers.

  • One example of a list that has this issue has 76 sections and 1733 items, I dont know if this helps, I cant share the list object sorry

Video of the issue

SVID_20210831_132515_1.mp4

Structure of sectionItems is:

[
// Section 1
[ { item1 } , { item2 }, { item3 } ],
// Section 2
[ { item4 }, {item5 }, { item6 } ],
…etc
]

  • There is no issue here everything works perfectly. I'm just mentioning it.

The props I use in BigList:

bounces={false}
sections={this.state.sectionItems}
renderItem={this.renderProducts}
itemHeight={204}
numColumns={2}
showsVerticalScrollIndicator={false}

Additional info:

It happens only when I dont have section headers. When I use section headers by inserting these props below everything works ok.

renderSectionHeader={this.renderSectionHeader}
sectionHeaderHeight={40}

Don't support reanimated-2 for onScroll

  1. reanimated 2 don't supported, even if createAnimatedComponent applied to BigList.
  2. at the end of each scroll there's a lag.

const AnimatedAdvancedFlatList = Animated.createAnimatedComponent(BigList);

const onScroll = useAnimatedScrollHandler(({ contentOffset: { y } }) => {
console.log("done");
headerY.value = y;
});

BigList Crashes With the placeholder prop set to true

On a list of contacts, loaded in the BigList, when the placeholder prop is set to true, on the first scroll itself the app crashes. No errors are seen on the console. I am using the expo client for Android.

However when the list is small in size with say a few records like 20 to 30 and the placeholder prop is set to true, one can see the gray-colored images upon scroll. Setting the placeholderImage for a small-sized list, loads the placeholder image too.

placeholder={true}
placeholderImage={require("../../assets/images/heart-empty.png")}

So I think there is some memory leak happening for a list with a large number of items, and the props placeholder is not working. Please can anybody confirm this?

Looking forward to a fix for this as the blank screen on the fast scroll is a problem.

onViewableItemsChanged called 2 times

Hello
i love this package its the best really
but there is issue really annoying me
i use this package for videos timeline like tiktok so i have 1 item per window height
the problem is after 6 or 8 elements onViewableItemsChanged start to be called 2 by 2 not 1 by 1 like normal
so the item on the viewport is isViewable = false and the next one is true

 <BigList
        data={data}
        keyExtractor={(i, x) => `item_${i.id.toString()}`}
        renderItem={renderItem}
        itemHeight={height}
        snapToInterval={height}
        windowSize={1}
        initialNumToRender={1}
        maxToRenderPerBatch={1}
        removeClippedSubviews={true}
        showsVerticalScrollIndicator={false}
        pagingEnabled
        snapToAlignment="center"
        decelerationRate="fast"
        disableIntervalMomentum
        viewabilityConfig={{
          itemVisiblePercentThreshold: 100,
          minimumViewTime: 500,
          viewAreaCoveragePercentThreshold: 100,
        }}
        onViewableItemsChanged={onViewableItemsChanged}
      />

const onViewableItemsChanged = useCallback(({ viewableItems, changed }) => {
    const now = viewableItems[0].item;
    const old = changed[0].item;

    console.log("old.id", old.id);
    console.log("now.id", now.id);
  }, []);

useScrollToTop from '@react-navigation/native' error

Hello Marco,

Thank you for all the hard work.

I am trying to implement useScrollToTop with BigList and i'm getting the following error

'undefined is not an object (evaluating '_ref7.animated')

Im following the instructions from the react navigation docs

Here is my code

import { useScrollToTop } from '@react-navigation/native'

const MyScreen = () => {

       const bigListRef = useRef()
       useScrollToTop(bigListRef)

              return (
                  <BigList
                    ref={bigListRef}
                   ....
                   />
                   )
}

`ScrollViewComponent` of type `object` supplied to `BigList`

i have copied the same example as you mentioned but i got this error ?
` <BigList
headerHeight={100} // Default 0, need to specify the header height
footerHeight={100} // Default 0, need to specify the footer height

    //  renderEmpty={renderItemEmpty}
      ListEmptyComponent= {renderItemEmpty}
      placeholder
      onRefresh={() => onRefresh()}
      refreshing={state.isFetching}          
      contentContainerStyle={{
       display:"flex",
       alignItems:"center",
       justifyContent:"center"
        }}
      data={data}
      placeholderComponent={()=>(<View />)}
      ScrollViewComponent ={ScrollView}
     // renderItem={({item,index})=>renderItem({item,index}) }
      renderItem={renderItem}
      itemHeight={height+20} 
      keyExtractor={(item, index) => `keyExtractor_${index.toString()}`}
      ListFooterComponent={renderLoader}
      onEndReached={loadMore}
      onEndReachedThreshold={0.01}
      initialNumToRender={100}   
  />

`

Warning: Failed prop type: Invalid prop ScrollViewComponent of type object supplied to BigList, expected function.

onViewableItemsChanged no triggered after the first section

Hello,

I use the Section List to display an alphabetical list of contacts. Each section correspond to a letter of the alphabet. Next to the list, there is a vertical component that display an alphabetical index (A to Z).

I would like to highlight the active section (letter) on this component. For that, the onViewableItemsChanged callback seems to be the answer.

However, it is not working as expected.

The event is only fired for the first section (in my contact app example, for the letter "A"). When the user scroll to the next section, the event is not triggered at all.

Thanks

support for masonry/staggered layout

the performance of this BigList is actually incredible so its would be really nice if this library had support for staggered layout, right now the only performant list library that has support for staggered layout is react-native-large-list, but that library have serious problems with actual large list of items and it also brakes a lot.

request + bug(s): add prop to specify default shimmer height

the title

I noticed that the shimmer seems to change sizes, when the loading is finalizing, shimmer item change to a smaller height, would help to keep the same height size always.

I tried specifying a custom placeholder component, but only showed a single shimmer item, instead of in each of the spaces waiting to be loaded.

Also if the list is long, it's like the shimmer doesnt fill all of the spaces if you continue to scroll, I got a half shimmer once, and when I continued to scroll without stop, it was blank space, that's probably another bug.

Edit: I see why, if I quick scroll and there is only a handful of items, it's like your shimmer tries to squeeze to fit, therefore it get smaller, it's like a fixed image, can you make so it's component based on the amount of items waiting to be loaded given where you are on the scroll?

I'm using v1.4.2

Style of item gets recycled

Hi Marco, thank you so much for this great list.

My problem is: I have a list with selectable items, so the style of an item inside of the list depends on a local state (meaning the state is defined inside of the item component). If, for example, I select the first item in the list, its style gets changed but when I scroll down every 21st item is selected and its style is also changed event though I did not select those items. I know that this happens because of the recycling mechanism.

How would you solve this problem?

bug / when list is empty, header is shown below

Hey, there is a bug with the renderHeader, if the list is empty and I have set the renderEmpty the renderHeader is rendered below the renderEmpty, it should most likely be rendered above, since it's the header.

Edit:
If I set hideFooterOnEmpty it hides the renderHeader which seems to be set as footer when the list is empty. There is no renderFooter set.
But if I set hideHeaderOnEmpty and remove hideFooterOnEmpty it hides the renderEmpty component and show the header instead.

BigList Sections - TypeError: Attempted to assign to readonly property.

I'm using the Section List Example 1:1 from here https://marcocesarato.github.io/react-native-big-list-docs/basics/sections-list/

When I render the List in my View I'm getting:

TypeError: Attempted to assign to readonly property.

This error is located at:
    in BigListItem
    in BigListItem (created by BigList)
    in RCTScrollContentView (at ScrollView.js:1124)
    in RCTScrollView (at ScrollView.js:1260)
    in ScrollView (at ScrollView.js:1286)
    in ScrollView (created by BigList)
    in RCTView (at View.js:34)
    in View (created by BigList)
    in BigList (at order-list/index.js:113)
    in OrderList (at orders/index.js:57)
    in RCTView (at View.js:34)
    in View (created by Layout)
    in Layout (created by Context.Consumer)
    in Wrapper (created by Layout)
    in Layout (at orders/index.js:56)
    in OrdersView (at SceneView.tsx:126)
    in StaticContainer
    in StaticContainer (at SceneView.tsx:119)
    in EnsureSingleNavigator (at SceneView.tsx:118)
    in SceneView (at useDescriptors.tsx:209)
    in RCTView (at View.js:34)
    in View (at DebugContainer.native.tsx:27)
    in DebugContainer (at NativeStackView.native.tsx:71)
    in MaybeNestedStack (at NativeStackView.native.tsx:228)
    in RNSScreen (at createAnimatedComponent.js:165)
    in AnimatedComponent (at createAnimatedComponent.js:215)
    in ForwardRef(AnimatedComponentWrapper) (at src/index.native.tsx:150)
    in Screen (at NativeStackView.native.tsx:175)
    in SceneView (at NativeStackView.native.tsx:276)
    in RNSScreenStack (at NativeStackView.native.tsx:267)
    in NativeStackViewInner (at NativeStackView.native.tsx:321)
    in SafeAreaProviderCompat (at NativeStackView.native.tsx:320)
    in NativeStackView (at createNativeStackNavigator.tsx:67)
    in NativeStackNavigator (at navigation/index.js:45)
    in OrdersNavigator (at SceneView.tsx:126)
    in StaticContainer
    in StaticContainer (at SceneView.tsx:119)
    in EnsureSingleNavigator (at SceneView.tsx:118)
    in SceneView (at useDescriptors.tsx:209)
    in RCTView (at View.js:34)
    in View (at Screen.tsx:61)
    in RCTView (at View.js:34)
    in View (at Background.tsx:13)
    in Background (at Screen.tsx:56)
    in Screen (at BottomTabView.tsx:129)
    in RNSScreen (at createAnimatedComponent.js:165)
    in AnimatedComponent (at createAnimatedComponent.js:215)
    in ForwardRef(AnimatedComponentWrapper) (at src/index.native.tsx:150)
    in Screen (at ScreenFallback.tsx:37)
    in MaybeScreen (at BottomTabView.tsx:122)
    in RNSScreenContainer (at src/index.native.tsx:189)
    in ScreenContainer (at ScreenFallback.tsx:28)
    in MaybeScreenContainer (at BottomTabView.tsx:93)
    in SafeAreaProviderCompat (at BottomTabView.tsx:92)
    in BottomTabView (at createBottomTabNavigator.tsx:112)
    in Unknown (at createBottomTabNavigator.tsx:111)
    in BottomTabNavigator (at navigation/index.js:66)
    in TabNavigator (at SceneView.tsx:126)
    in StaticContainer
    in StaticContainer (at SceneView.tsx:119)
    in EnsureSingleNavigator (at SceneView.tsx:118)
    in SceneView (at useDescriptors.tsx:209)
    in RCTView (at View.js:34)
    in View (at DebugContainer.native.tsx:27)
    in DebugContainer (at NativeStackView.native.tsx:71)
    in MaybeNestedStack (at NativeStackView.native.tsx:228)
    in RNSScreen (at createAnimatedComponent.js:165)
    in AnimatedComponent (at createAnimatedComponent.js:215)
    in ForwardRef(AnimatedComponentWrapper) (at src/index.native.tsx:150)
    in Screen (at NativeStackView.native.tsx:175)
    in SceneView (at NativeStackView.native.tsx:276)
    in RNSScreenStack (at NativeStackView.native.tsx:267)
    in NativeStackViewInner (at NativeStackView.native.tsx:321)
    in RNCSafeAreaProvider (at SafeAreaContext.tsx:76)
    in SafeAreaProvider (at SafeAreaProviderCompat.tsx:38)
    in SafeAreaProviderCompat (at NativeStackView.native.tsx:320)
    in NativeStackView (at createNativeStackNavigator.tsx:67)
    in NativeStackNavigator (at navigation/index.js:129)
    in EnsureSingleNavigator (at BaseNavigationContainer.tsx:429)
    in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:132)
    in ThemeProvider (at NavigationContainer.tsx:131)
    in ForwardRef(NavigationContainerInner) (at navigation/index.js:104)
    in AppNavigator (at App.js:58)
    in RCTView (at View.js:34)
    in View (created by ModalPanel)
    in ModalPanel (created by ApplicationProvider)
    in ThemeProvider (created by StyleProvider)
    in MappingProvider (created by StyleProvider)
    in StyleProvider (created by ApplicationProvider)
    in ApplicationProvider (at App.js:53)
    in RNCAppearanceProvider (at src/index.tsx:70)
    in AppearanceProvider (at App.js:51)
    in AuthProvider (at App.js:50)
    in QueryClientProvider (at App.js:49)
    in Unknown (created by ExpoRoot)
    in ExpoRoot (at renderApplication.js:45)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:106)
    in DevAppContainer (at AppContainer.js:121)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:132)
    in AppContainer (at renderApplication.js:39)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:43:2 in showErrorDialog
at [native code]:null in commitRootImpl
at [native code]:null in performSyncWorkOnRoot
at [native code]:null in callFunctionReturnFlushedQueue

When I remove

      renderHeader={renderHeader}
      renderFooter={renderFooter}
      renderSectionHeader={renderSectionHeader}
      renderSectionFooter={renderSectionFooter}

the error is gone.

Blank list

I follow the example from your project and documentation and got a blank screen.

Code -

import React from 'react';
import {Text} from 'react-native';
import BigList from 'react-native-big-list';

const data = [
  {label: '1', value: 1},
  {label: '2', value: 2},
  {label: '3', value: 3},
  {label: '4', value: 4},
  {label: '5', value: 5},
];
const renderItem = ({item, index}) => (
  <>
    <Text>1</Text>
    <Text>{item.label}</Text>
    <Text>{item.value} </Text>
  </>
);
const renderEmpty = () => <Text>Empty</Text>;
const renderHeader = () => <Text>Header</Text>;
const renderFooter = () => <Text>Footer</Text>;

const HomeScreen = () => {
  return (
    <>
      <Text>hi</Text>
      <BigList
        data={data}
        renderItem={renderItem}
        renderEmpty={renderEmpty}
        renderHeader={renderHeader}
        renderFooter={renderFooter}
        itemHeight={50} // Required (default 0)
        headerHeight={90} // Required to show header
        footerHeight={100} // Required to show footer
      />
    </>
  );
};

export default HomeScreen;

Config -

"dependencies": {
    "react": "17.0.2",
    "react-native": "0.65.2",
    "react-native-big-list": "^1.4.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.0",
    "react-native-codegen": "^0.0.7",
    "react-test-renderer": "17.0.2"
  },

Result -
Screenshot_1636018402

renderItem is not being called after switching from FlatList

I've installed BigList and followed the 'Migrate from FlatList' guide, after which the component looks like this:

console.log('about to try to use biglist'); // This shows up
<BigList
    data={item}
    renderItem={(item) => {
        console.log('WITHIN RENDERITEM'); // This never shows up in console
        return <MenuListItem 
            food={item.item} 
            navigation={this.props.navigation} 
            onItemPress={() => { 
                this.props.dispatch(loadCurrentMenuItem('fooditem', item.item));
                this.props.navigation.navigate('ViewFoodItem', {
                    fid: item.item.id
                });
            }}
        />
    }}
    itemHeight={50}//swapped out the const just to show the current value
    keyExtractor={(item, index) => index.toString()}
/>

No items are rendered and that console.log() within the renderItem function never shows up.

If I switch back to FlatList and remove the itemHeight property everything is displayed properly again.

In the migration guide it specifically says "The main props of FlatList are compatible with BigList like data". Are there exceptions to that? Does it not extend to renderItem and I need to download the examples to see how the needs of that have changed?

I should also ask since this is mentioned on the front page: 'When list can't render your items fast enough the non-rendered components will appear as blank space.' Since I am currently experiencing this problem with categories further down my list being blank, will BigList do anything to fix that or will it have the same problems FlatList has? I saw another issue elsewhere mention that they were still having the same blank space issues while using this plugin.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.