react-infinite-scroll-component 在反应中,一个非常棒的无限滚动组件

使用一个组件,让你所有的无限滚动的痛苦消失,只有4.15kB!Pull Down to Refresh新增功能。一个无限的滚动,实际工作和超级简单的集成!

 

安装
  npm install --save react-infinite-scroll-component

  // in code ES6
  import InfiniteScroll from 'react-infinite-scroll-component';
  // or commonjs
  var InfiniteScroll = require('react-infinite-scroll-component');

 

使用

<InfiniteScroll
  dataLength={items.length} //This is important field to render the next data
  next={fetchData}
  hasMore={true}
  loader={<h4>Loading...</h4>}
  endMessage={
    <p style={{textAlign: 'center'}}>
      <b>Yay! You have seen it all</b>
    </p>
  }
  // below props only if you need pull down functionality
  refreshFunction={this.refresh}
  pullDownToRefresh
  pullDownToRefreshContent={
    <h3 style={{textAlign: 'center'}}>&#8595; Pull down to refresh</h3>
  }
  releaseToRefreshContent={
    <h3 style={{textAlign: 'center'}}>&#8593; Release to refresh</h3>
  }>
  {items}
</InfiniteScroll>

 

这个InfiniteScroll组件可以通过三种方式使用。

  • height如果你想要你的道具可滚动内容具有特定高度,提供滚动条以滚动内容并获取更多数据。
  • 如果你可滚动内容呈现在已提供溢出滚动条的父元素中,可以将scrollableTarget支持引用DOM元素并使用它的滚动条获取更多数据。
  • 而不设置heightscrollableTarget道具,滚动将发生在document.body喜欢Facebook的时间轴卷轴。

 

 

例子

API

请转https://github.com/ankeetmaini/react-infinite-scroll-component

 

 

 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值