码迷,mamicode.com
首页 > 其他好文 > 详细

[React] Create an Auto Resizing Virtualized List with react-virtualized

时间:2017-06-27 08:09:31      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:ons   count   scrolling   div   return   component   sso   iss   class   

In this lesson we‘ll show how to use the AutoSizer component from react-virtualized to automatically measure the width/height of our content area. We‘ll then use theList component to render our set of data as a virtualized list into the DOM using windowing.

 

Install:

npm install --save react-vistualized

 

import React, {Component} from ‘react‘;
import {AutoSizer, List} from ‘react-virtualized‘;

const ScreenInfo = ({width, height}) => (<span>width: {width} height: {height}</span>);

class App extends Component {

    renderRow = ({key, isScrolling, style, index}) => {
        return (
            <div style={style} key={key}>
                name: {this.props.data[index].name}
                email: {this.props.data[index].email}
            </div>
        );
    };

    render() {
        return (
            <AutoSizer>
                {({width, height}) => {
                    return (
                        <div>
                            <ScreenInfo width={width} height={height}/>
                            <List
                                rowCount={this.props.data.length}
                                rowHeight={50}
                                rowRenderer={this.renderRow}
                                width={width}
                                height={height}
                            />

                        </div>
                    );
                }}
            </AutoSizer>
        );
    }
}

export default App;

 

[React] Create an Auto Resizing Virtualized List with react-virtualized

标签:ons   count   scrolling   div   return   component   sso   iss   class   

原文地址:http://www.cnblogs.com/Answer1215/p/7083155.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!