question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inverted Flatlist(VirtualizedList) with specific conditions has rendering problem.

See original GitHub issue

The problem Flatlist(VirtualizedList) has problem specific conditions in Web This list rendered the wrong range of index items, Sometimes It is rendered again constantly

How to reproduce Simplified test case: https://snack.expo.io/@kunhee_lee/kunhee_lee_test

Steps to reproduce:

  1. Just scroll up the list
  2. If you scroll up to near by 70~80 , you can see the malfunction
  3. this problem is happend when renderitem has numberic height (ex: maybe upper than 40)

Expected behavior react-native-web/packages/react-native-web/src/vendor/reactnative/VirtualizeUtils/VirtualizeUtils.js

...
const leadFactor = 0.5; // Math.max(0, Math.min(1, velocity / 25 + 0.5));

  const fillPreference =
    velocity > 1 ? 'after' : velocity < -1 ? 'before' : 'none';

  const overscanBegin = Math.max(0,visibleBegin - (1 - leadFactor) * overscanLength, );
  const overscanEnd = Math.max(0, visibleEnd + leadFactor * overscanLength);

  const lastItemOffset = getFrameMetricsApprox(itemCount - 1).offset;
  if (lastItemOffset < overscanBegin) {
    // Entire list is before our overscan window
    return {
      first: Math.max(0, itemCount - 1 - maxToRenderPerBatch),
      last: itemCount - 1,
    };
  }
...

leadFactor(0.5) is not suitable value with some conditions this makes the overscanBegin value bigger than 0 so It cause the wrong retern with wrong first, last If you fix this value leadFactor, this matter would is solved I have tried to make correct formula for leadFactor

Environment (include versions). Did this work in previous versions?

  • React Native for Web (version): 0.12.2
  • React (version): 16.9.0
  • Browser: Chrome

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
azesmwaycommented, Jan 12, 2022

@azesmway have you updated this to work with “react-native-web”: “0.17.1”? Looks like these changes are already there, but I’m seeing the same issue still.

Hi I found solution easier

node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js

string 653 newState = computeWindowedRenderLimits(_this.props, state, _this._getFrameMetricsApprox, _this._scrollMetrics); newState.first = 0; // <— this change

2reactions
necolascommented, Oct 12, 2020

I reopened that issue. If someone writes a PR for RN that improves compatibility on web without negatively effecting RN, I will help get the review prioritized

Read more comments on GitHub >

github_iconTop Results From Across the Web

VirtualizedList - React Native
Virtualization massively improves memory consumption and performance of large lists by maintaining a finite render window of active items ...
Read more >
React Native flatlist inverted - Stack Overflow
<FlatList data={data.reverse()} inverted={true} And then i have the normal renderItem function for the messages.
Read more >
Meet FlashList: A better alternative to FlatList for React Native
VirtualizedList: You have a large list that is slow to update — make sure your renderItem function renders components that follow React performance...
Read more >
A deep dive into React Native FlatList - LogRocket Blog
FlatList is a React Native component that allows you to render ... Here, we are using conditional rendering to check if the data...
Read more >
FlatList · React Native 中文
This is a PureComponent which means that it will not re-render if props remain shallow- equal. Make sure that everything your renderItem function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found