React Virtualized-列表跳过其他所有项目

时间:2019-04-23 14:32:30

标签: reactjs react-virtualized

我真的不明白我在做什么,按照文档去做。
标题说明:
当我从1滚动到2时(即1现在已隐藏)-一切都很好。
当我从2滚动到3时(即1和2现在都被隐藏了)-列表跳了,所以它不是从项目3开始的,而是从项目4开始的。
当我一直向下滚动时,我将拥有所有跳过项目的其余部分,这意味着其中有一个空白空间,其中不存在任何项目。
这是我的代码:


class MyList extends React.Component {
    rowRenderer = (params: any): JSX.Element => {
       const color = params.index % 2 ? 'white' : 'blue';
       return (
          <div style={{height: 50, backgroundColor: color}}>
             {this.items[params.index]}
          </div>
       );
    }

    render() {
       <div style={{height: 300}}>
           <List
               height={300}
               width={235}
               rowHeight={50}
               rowCount={this.items.length}
               rowRenderer={this.rowRenderer}
           />
       </div>
    }
}

0 个答案:

没有答案
相关问题