question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlatList renders only 10 items when in BottomNavigation

See original GitHub issue

Current behaviour

When one of the items in renderScene is a FlatList, only the first 10 (or initialNumToRender) items are rendered.

Expected behaviour

The same number of items rendered by the FlatList as if the FlatList is rendered outside of BottomNavigation.

Code sample

import React, { Component } from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    View,
    FlatList
} from 'react-native';
import { BottomNavigation } from 'react-native-paper';

export default class RouteSelectorTabs extends Component {

    constructor(props) {
        super(props);
        this.state = {
            index: 0,
            routes: [
                { key: 'flatlist', title: 'FlatList', icon: 'list' },
            ],
            itemsList: [
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
                "Item",
            ]
        }
    }

    handleIndexChange(index) {
        this.setState({ index });
    }

    renderScene({ route, jumpTo }) {
        return <FlatList
            data={this.state.itemsList}
            //initialNumToRender={20}
            renderItem={({ item, index }) => {
                return <Text key={item.code}>{"item " + index}</Text>;
            }}
            keyExtractor={(item, index) => "key" + index}
        />
    }

    render() {
        return (
            <BottomNavigation
                style={{}}
                shifting={false}
                navigationState={this.state}
                onIndexChange={this.handleIndexChange.bind(this)}
                renderScene={this.renderScene.bind(this)}
            />
        );
    }
}

Your Environment

software version
ios 11.2
react-native 0.54.0
react-native-paper 1.1.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
Andersonfrfilhocommented, Sep 27, 2019
<FlatList
      data={data}
     initialNumToRender={data.length}
      renderItem={({item}) => {
      console.tron.log(item.id);
      }}
/>

solved for me but I don’t know why this problem is happening adding in her attributes. initialNumToRender={data.length}

5reactions
satya164commented, Mar 9, 2018

Try adding style={{ flex: 1 }} in your FlatList

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native FlatList only renders 10 items - Stack Overflow
I did this but now it's only displaying 50. Still won't load more. Ideally I'd like to initially render 10 then load the...
Read more >
FlatList breaking above 10 items : r/reactnative - Reddit
Having an issue with my FlatLists in an app I'm working on, they render perfectly with <10 items, but more than that and...
Read more >
Supporting safe areas | React Navigation
While React Native exports a SafeAreaView component, it has some inherent issues, i.e. if a screen containing safe area is animating, it causes...
Read more >
React List component - Material UI - MUI
Lists are a continuous group of text or images. They are composed of items containing primary and supplemental actions, which are represented by...
Read more >
react native flatlist from bottom to top Code Example
react native flatlist margin bottom ... native component at bottom center · flatlist only rendering 10 items · react native button top right....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found