[FlatList] Rows aren't rendered until scroll
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.

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.
+1 Encountering exactly the same problem. Worked with 0.5 but broke with 0.6.
This should be fixed in 0.7
I was experience the same exact problem.
cloneWithRows works fine. but cloneWithRowsandSections doesn't.
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.
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 :)
Having the same issue with cloneWithRows in version 0.6, was working in 0.5.
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.
worked in 0.7
Also not working in 0.7.1
Having the same issue with cloneWithRows in version 0.7.1
For me it works well in 0.7.1.
Does not work in 0.8.0.
Still using cloneWithRows instead of cloneWithRowsAndSections
cloneWithRows works for you yamill? Doesn't for me in 0.8.0.
@coderdave actually cloneWithRows doesn't work for me either. my mistake.
@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;
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.
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 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.
+1 for me, I'm currently encountering this behaviour when using Navigator. I'm on 0.11 and I use cloneWithRows.
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);