简体   繁体   English

React Virtualized - 滚动一长串列表后屏幕变黑

[英]React Virtualized - Screen going blank after scrolling a long list of itsm

I'm working on a long list of items.我正在处理一长串项目。 For that I'm using react-virtualized ( https://github.com/bvaughn/react-virtualized ).为此,我使用 react-virtualized ( https://github.com/bvaughn/react-virtualized )。 But I'm facing the below issue.但我面临以下问题。

在此处输入图像描述

When I try scrolling to the bottom for 2 seconds, it's blank then data is loading.当我尝试滚动到底部 2 秒时,它是空白的,然后数据正在加载。 It's not very smooth.它不是很顺利。 This https://2v9j5.csb.app/ is the CodeSandBox link.这个https://2v9j5.csb.app/是 CodeSandBox 链接。

As I inspected in this use case we shouldn't remount the root div for the rowRenderer : <div key={key} style={style}> on scrolling as used on the docs , so this should fix the performance problem:正如我在这个用例中检查的那样,我们不应该重新安装rowRenderer的根 div : <div key={key} style={style}>在滚动时使用docs ,所以这应该可以解决性能问题:

function rowRenderer({ key, index, isScrolling, style }) {
  const content = isScrolling ? (
    <div>Scrolling...</div>
  ) : (
    <ListItem idx={index} item={airports[index]} />
  );
  return (
    <div key={key} style={style}>
      {content}
    </div>
  );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM