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

[FlatList] Rows aren't rendered until scroll

Open michalraska opened this issue 11 years ago • 223 comments

Hi, I have list view which displays partially local and partially remote data. Local data are initial for ListView.DataSource. This datasource is set in state of my custom component which wraps ListView and passed in render method to ListView. When are remote data received, new datasource is cloned by cloneWithRowsAndSections method and set to state of custom component. Problem is that are re-rendered only already displayed rows and new rows are rendered after scroll.

renderbug

Is it bug or how I should to force rendering of ListView? With react-native 0.5 it worked but after upgrade to 0.6 it behaves as described above.

michalraska avatar Jul 01 '15 13:07 michalraska

+1 Encountering exactly the same problem. Worked with 0.5 but broke with 0.6.

Furizaa avatar Jul 02 '15 07:07 Furizaa

This should be fixed in 0.7

ide avatar Jul 02 '15 08:07 ide

I was experience the same exact problem.

cloneWithRows works fine. but cloneWithRowsandSections doesn't.

yamill avatar Jul 02 '15 18:07 yamill

Are you seeing cloneWithRowsandSections not working with 0.7?

Also, you might want to try setting initialListSize to a larger number - that might help as a workaround if things aren't fixed in 0.7 for you.

sahrens avatar Jul 02 '15 23:07 sahrens

Bigger initialListSize does not help and 0.7 I have not tried yet because vendors dependency. As it will be possible I let you know about 0.7 if somebody will not be quicker :)

michalraska avatar Jul 03 '15 08:07 michalraska

Having the same issue with cloneWithRows in version 0.6, was working in 0.5.

coderdave avatar Jul 04 '15 01:07 coderdave

Haven't tried it in 0.7. Will give it a try. I know that I also had tried setting the initialListSize to a higher number previously and didn't help.

yamill avatar Jul 04 '15 13:07 yamill

worked in 0.7

Shimaa-Hassan avatar Jul 08 '15 15:07 Shimaa-Hassan

Also not working in 0.7.1

coderdave avatar Jul 12 '15 04:07 coderdave

Having the same issue with cloneWithRows in version 0.7.1

ghislaindj avatar Jul 15 '15 13:07 ghislaindj

For me it works well in 0.7.1.

michalraska avatar Jul 23 '15 10:07 michalraska

Does not work in 0.8.0.

Still using cloneWithRows instead of cloneWithRowsAndSections

yamill avatar Jul 29 '15 20:07 yamill

cloneWithRows works for you yamill? Doesn't for me in 0.8.0.

coderdave avatar Jul 29 '15 21:07 coderdave

@coderdave actually cloneWithRows doesn't work for me either. my mistake.

yamill avatar Jul 29 '15 21:07 yamill

@sahrens @ide @michalraska my scrollY prop was not getting updated. I was basically trying to pass the scroll offset to my component, like so:

    renderRow: function (rowData, sectionID, rowID) {
          return (
            <Row
            key={rowData.id} data={rowData} scrollY={this.state.contentOffset}
             />
          )
    });

But fixing this line allowed me to receive the scrollY prop to my component successfully. I wonder if this change fixes all others issues?

https://github.com/facebook/react-native/blob/757d6d204ae2d743634af64e3f78a4aad9d53f70/Libraries/CustomComponents/ListView/ListView.js#L342-L343

I changed it from:

var shouldUpdateRow = rowCount >= this.state.prevRenderedRowsCount && dataSource.rowShouldUpdate(sectionIdx, rowIdx);

to

var shouldUpdateRow = true;

yamill avatar Jul 30 '15 15:07 yamill

I've noticed this on 0.11.0-rc as well.

Here are two examples that can reproduce the issue.

Rows: https://rnplay.org/apps/d3DM6A Rows + Sections: https://rnplay.org/apps/xnyaYw

The temporary solution that I came up with was to scroll the ListView 1pt when it mounts.

let listViewScrollView = this.refs.listView.getScrollResponder();
listViewScrollView.scrollTo(1);

You can uncomment this section inside the example on rnplay.org for testing.

christopherdro avatar Sep 13 '15 18:09 christopherdro

Silly question. Could this have anything to do with using NavigatorIOS? I've had some issues w/ rendering, padding, etc all when a list view was rendered as a child of NavigatorIOS.

jaygarcia avatar Sep 13 '15 19:09 jaygarcia

@jaygarcia I don't think so since the example's don't make use of NavigatorIOS. Also, in my own project I'm using Navigator instead of NavigatorIOS.

christopherdro avatar Sep 13 '15 19:09 christopherdro

+1 for me, I'm currently encountering this behaviour when using Navigator. I'm on 0.11 and I use cloneWithRows.

Intellicode avatar Sep 17 '15 08:09 Intellicode

As workaround, I had to use @christopherdro's solution, but I would need to scroll it sufficiently much to get my items rendered (they are big).

Interestingly, the work around is related to the workaround for this bug: https://github.com/facebook/react-native/issues/1878 so my final code is:

    listViewScrollView.scrollWithoutAnimationTo(80);
    listViewScrollView.scrollWithoutAnimationTo(-80);

Intellicode avatar Sep 17 '15 09:09 Intellicode