react-native-big-list icon indicating copy to clipboard operation
react-native-big-list copied to clipboard

renderItem is not being called after switching from FlatList

Open bmcn99 opened this issue 3 years ago • 13 comments

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.

bmcn99 avatar Jan 06 '22 06:01 bmcn99

@marcocesarato

lamlengend98 avatar Jan 07 '22 07:01 lamlengend98

yeah i am facing the same issue the items are not being rendered just a blank screen

afkcodes avatar Feb 20 '22 10:02 afkcodes

i have the same problem and on my side renderEmpty is always called even if data is not empty.

allemanfredi avatar Feb 23 '22 12:02 allemanfredi

double check the name of your data variable, maybe try to rename it because the mess of item variables may be the problem

labtorie avatar Feb 23 '22 12:02 labtorie

The variable names were correct in my example there, and worked in the original FlatList (Aside from the blank space issue with items towards the bottom of the list). I think in the end we increased the SectionList initialNumToRender property from the default of 10 to a higher amount. The SectionList was using FlatLists for its sections. I was worried it would increase memory usage and introduce a new problem that way but we haven't seen any issues from it.

bmcn99 avatar Feb 23 '22 19:02 bmcn99

@marcocesarato can you have a look at this please i want to use this but this issue keeps me out.

afkcodes avatar Feb 23 '22 20:02 afkcodes

@bmcn99 can you please provide the data structure you use as the 'data' prop?

labtorie avatar Feb 25 '22 08:02 labtorie

@labtorie i just tried with [1,2,3,4,5] and renderItem is not called yet. Just renderEmpty is called.

allemanfredi avatar Feb 25 '22 13:02 allemanfredi

Same issue over here.

captainvarun avatar Mar 08 '22 12:03 captainvarun

@marcocesarato any news here?

allemanfredi avatar Mar 15 '22 13:03 allemanfredi

Same issue over here.

I was able to resolve the issue by downgrading to version 1.5.0 and also by adding a height of 100% to the view above BigList.

captainvarun avatar Mar 21 '22 07:03 captainvarun

struggling with the same issue, makes the library unusable unfortunately. any news on this? id really like to use the package otherwise

Sir-hennihau avatar Nov 02 '23 21:11 Sir-hennihau

The reason for an empty component in my case was the missing height on the parent element of my BigList.

Solution was to add a <View> with 100% height around the <BigList> component.

<View style={{height: '100%'}}>
  <BigList ... />
</View>

scriptlabs avatar Nov 04 '23 00:11 scriptlabs