Native Refresh
npm install react-native-refresh-control-enrichment --saveor using yarn:
yarn add react-native-refresh-control-enrichmentAfter that, we need to install the dependencies to use the project on iOS(you can skip this part, if you are using this on Android)
Now run:cd ios && pod install
import ZHRefreshControl, {ZHScrollView} from 'react-native-refresh-control-enrichment';
<ZHScrollView
style={{flex: 1}}
refreshControl={
<ZHRefreshControl
ref={(r) => this._finishRefresh = r}
headerHeight={80} // headerHeight
headerBackgroundColor={'#e6e6e6'} // headerBackgroundColor and headerBackgroundImage, do not combine
onRefresh={()=>{
console.log('======== Refreshing ========');
setTimeout(()=>{
// Refreshing End
this._finishRefresh.finishRefresh();
console.log('======== Refreshing End ========');
},2000)
}}
/>
}
>
<View style={{flex: 1, height: 1000, backgroundColor: '#dddddd', alignItems: 'center', paddingTop: 300}}>
<Text style={{color: '#000', fontSize: 16}}>⬇️ down 😊</Text>
</View>
</ZHScrollView>import {FlatList} from 'react-native';
import ZHRefreshControl, {ZHScrollView} from 'react-native-refresh-control-enrichment';
<FlatList
data={['#8c4fff', '#f0b1ff', '#908c95', '#effba5', '#2b2cff', '#009c18']}
renderScrollComponent={(props) => (
<ZHScrollView
style={{flex: 1}}
refreshControl={
<ZHRefreshControl
ref={(r) => this._finishRefresh = r}
headerHeight={80} // headerHeight
headerBackgroundColor={'#e6e6e6'} // headerBackgroundColor and headerBackgroundImage, do not combine
onRefresh={()=>{
console.log('======== Refreshing ========');
setTimeout(()=>{
// Refreshing End
this._finishRefresh.finishRefresh();
console.log('======== Refreshing End ========');
},2000)
}}
/>
}
{...props}
/>
)}
keyExtractor={(item, key) => key.toString()}
renderItem={({item, index}) => (
<View style={{backgroundColor: item, marginHorizontal: 15, height: 100, borderRadius: 20, marginTop: 15}}/>
)}
/>刷新时触发
| Type | Required |
|---|---|
| function | Yes |
刷新时状态
| Type | Required |
|---|---|
| function | Yes |
加载中View
| Type | Default |
|---|---|
| element | Yes |
头部高度
| Type | Default |
|---|---|
| number | 60 |
内容距离顶部高度(一般为状态栏高度)
| Type | Default |
|---|---|
| number | 0 |
头部背景色
| Type | Default |
|---|---|
| string | #ffffff |
头部背景图片
| Type | Required |
|---|---|
| url | Yes |
展示刷新状态
| Type | Default |
|---|---|
| boolean | Yes |
刷新状态字体样式
| Type | Default |
|---|---|
| style | Yes |
展示刷新时间
| Type | Default |
|---|---|
| boolean | Yes |
更新时间字体样式
| Type | Default |
|---|---|
| style | Yes |
自定义提示状态,注:数量需要为四个
| Type | Default |
|---|---|
| array | yes |
下拉 LoadingView
| Type | Default |
|---|---|
| element | Yes |
释放 LoadingView
| Type | Default |
|---|---|
| element | Yes |
成功 LoadingView
| Type | Default |
|---|---|
| element | Yes |
https://github.com/react-native-studio/react-native-SmartRefreshLayout
https://github.com/react-native-studio/react-native-MJRefresh

