Skip to content

VirtualizedList populated with getItem() only displaying the first 10 items #13509

Closed
@agmathew

Description

@agmathew

Description

When populating a VirtualizedList using getItem() (i.e. not using data), the list only shows the first 10 items even if getItemCount() returns a number more than 10. This seems to happen irrespective of the setting of initialNumberToRender and windowSize. I'd expect that you would be able to see all items in the list.

Reproduction Steps and Sample Code

export default class ListTest extends Component {
  render() {
    return (
      <View>
        <VirtualizedList
          initialNumberToRender={20}
          windowSize={21}
          getItemCount={(data) => 365}
          getItem={(data, index) => {
            return { key: index };
          }}
          keyExtractor={(item, index) => {
            return item.key;
          }}
          renderItem={({ item, index }) => {
            return (
              <View style={{height:50}}>
                <Text>{item.key}</Text>
              </View>
            );
          }}
        />
      </View>
    );
  }
}

Solution

I peeked at the source code, but couldn't find a clear fix.

Additional Information

  • React Native version: 0.43.3
  • Platform: iOS
  • Development Operating System: MacOS
  • Dev tools: XCode 8.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions