aksonov/react-native-tableview

Delay rendering large data sets while using Cell

Open

#22 ouverte le 15 oct. 2015

Voir sur GitHub
 (6 commentaires) (1 réaction) (0 assignés)Objective-C (179 forks)github user discovery
enhancementhelp wanted

Métriques du dépôt

Stars
 (1 410 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

While using the Cell component of the library I noticed that there is large delay if I initialize it with a large amount of data. It takes about 3-5 seconds to render.

I am doing something like this in my component with 1000 dummy elements initialized:

  var faker = require('faker');

  var LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';

  componentWillMount: function() {
    this.data = this.generateData();
  },

  generateData: function() {
    var data = [];
    for (var i = 0; i < 1000; i++) {
      data.push({
        image: faker.image.avatar(),
        title: ("ROW: " + i + " - " + LOREM_IPSUM)
      });
    }
    return data;
  },

  render: function() {
    let items = this.data.map((data) => (<Cell>
                        <Text>{data.title}</Text>
                    </Cell>));
    return (
            <TableView style={{flex:1}}
                       tableViewStyle={TableView.Consts.Style.Plain}
                       tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}
                       onPress={(event) => console.log(event)}>
                <Section arrow={false}>
                    {items}
                </Section>
            </TableView>
        );
  },

This issue is not reproducible if I change my implementation to be Item, rather than Cell, for large data sets. Before I start digging into the source I wanted to know if this is a known limitation with Cell (slowness with initializing large data sets).

Guide contributeur