-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (26 loc) · 726 Bytes
/
index.js
File metadata and controls
35 lines (26 loc) · 726 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
import React from 'react';
import {
ActivityIndicator,
View,
} from 'react-native';
import Default from './templates/Default'
function getProperty(object, string) {
if (!string) {
return null;
}
const arr = string.split('.');
let prop = object;
arr.forEach(key => (prop = prop && prop[key] && prop[key]));
return prop;
}
const Annotation = (property, LoadingIndicator = Default) => Child => (props) => {
const isLoading = getProperty(props, property);
if (isLoading) {
return (<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator />
</View>);
}
return (<Child {...props}/>);
};
Annotation.DEFAULT = Default;
export default Annotation