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

Re-Render takes some time

Open xempie opened this issue 7 years ago • 11 comments

I tried this and seems it fixed some of the FlatList issues but I noticed when I scroll back (top or bottom) (specially when I'm using images) it takes some time to re-render and display the blocks.

So it would be good if it has an offeset to pre-load some items before displaying in viewport in order to prevent the blank space between blocks which doen't look good.

Any idea?

xempie avatar Dec 15 '17 17:12 xempie

I'm also experiencing this. It can take a few seconds once it's scrolled to the top to render the items.

cjcheshire avatar Jan 18 '18 13:01 cjcheshire

is it after refresh or if you scroll fast?

st0ffern avatar Jan 18 '18 13:01 st0ffern

Only tested this on iOS so far by tapping the status bar clock to return to the top of the list.

cjcheshire avatar Jan 18 '18 14:01 cjcheshire

I noted the same issue on iOS. Interestingly, the React FlatList component wasn't having any performance issues on iOS but was extremely slow on Android. I created a new PlatformFlatList component that serves OptimizedFlatList on Android and it worked great - including on relatively underpowered Android devices that were really struggling.

https://gist.github.com/thame/a7e5c61e7bb3a6d56406db37da090a76

thame avatar Feb 04 '18 07:02 thame

@thame, feel free to create a PR. I think that this solution also should be implemented.

st0ffern avatar Feb 04 '18 11:02 st0ffern

@stoffern Would love to, complete git/React noob so no idea how :) But, this is an awesome component, thank you!

thame avatar Feb 04 '18 19:02 thame

@xempie is this issue only related to ios or android to?

st0ffern avatar Feb 05 '18 07:02 st0ffern

@stoffern Sorry for the delay, I'm subscribed now. The performance issue I was having was mostly on Android (which is why I preferred the basic FlatList on iOS).

thame avatar Feb 12 '18 23:02 thame

Quick and patchy fix for this is to never hide the first items. Make sure to add enough to fill the screen but not much more.

So in our case maximum items is 3, so we will never hide the first 3 items to avoid this 2-3 seconds white screen when scrolling to top.

So the _updateItem() function on OptimizedFlatList.js would look like this:

if (index != 0 && index != 1 && index != 2) {
  if (!this.rowRefs[index].ref) {
    return false;
  }
  this.rowRefs[index].ref.setVisibility(visibility);
  return visibility;
}

So basically: just wrapping the function content within an IF stating which items not to hide.

gonzaloreciog avatar Mar 10 '18 15:03 gonzaloreciog

This is still happening. Not fixed yet.

udarts avatar Mar 29 '19 10:03 udarts

Quick and patchy fix for this is to never hide the first items. Make sure to add enough to fill the screen but not much more.

So in our case maximum items is 3, so we will never hide the first 3 items to avoid this 2-3 seconds white screen when scrolling to top.

So the _updateItem() function on OptimizedFlatList.js would look like this:

if (index != 0 && index != 1 && index != 2) {
  if (!this.rowRefs[index].ref) {
    return false;
  }
  this.rowRefs[index].ref.setVisibility(visibility);
  return visibility;
}

So basically: just wrapping the function content within an IF stating which items not to hide.

Thanks...! This solved another issue of not showing the 1st item when data resets (Refresh func).

twsuneth avatar Nov 18 '19 09:11 twsuneth