React 中实现下拉刷新

下拉刷新在手机上的体验差一直是webapp的痛点,最终我发现了这款组件。

# 安装

npm install react-pull-to-refresh
1

# 使用

handleRefresh(resolve, reject) {
  // do some async code here
  if (success) {
    resolve();
  } else {
    reject();
  }
}
1
2
3
4
5
6
7
8
<ReactPullToRefresh
  onRefresh={this.handleRefresh}
  className="your-own-class-if-you-want"
  style={{
    textAlign: "center"
  }}
>
  <h3>Pull down to refresh</h3>
  <div>{items}</div>
  <div>etc.</div>
</ReactPullToRefresh>
1
2
3
4
5
6
7
8
9
10
11

# github

https://github.com/bryaneaton13/react-pull-to-refresh (opens new window)