-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (36 loc) · 1016 Bytes
/
index.js
File metadata and controls
38 lines (36 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react'
import { FlatList, Platform, ScrollView } from 'react-native'
import CustomRefreshControl from './RefreshControl'
export { CustomRefreshControl as RefreshControl }
export function patchFlatListProps(options = {}) {
try {
if (Platform.OS === 'web') {
setCustomFlatListWeb(options)
}
} catch (e) {
console.error(e)
}
}
function setCustomFlatListWeb(options) {
FlatList.defaultProps = {
...FlatList.defaultProps,
// eslint-disable-next-line react/display-name
renderScrollComponent: (props) => (
<ScrollView
{...props}
// eslint-disable-next-line react/prop-types
refreshControl={
props.onRefresh
? (
<CustomRefreshControl
{...options}
refreshing={props.refreshing}
onRefresh={props.onRefresh}
/>
)
: props.refreshControl // fallback to existing refreshControl if any
}
/>
),
};
}