-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathmakeMenuOptions.js
More file actions
29 lines (26 loc) · 896 Bytes
/
makeMenuOptions.js
File metadata and controls
29 lines (26 loc) · 896 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
const isClonable = (element) => !!element;
module.exports = (React, ReactNative, { styles }) => {
const { TouchableWithoutFeedback, View } = ReactNative;
const MenuOptions = React.createClass({
displayName: 'MenuOptions',
onSelect(value) {
this.props.onSelect(value);
},
render() {
return (
<TouchableWithoutFeedback style={[styles.options, this.props.style]}>
<View>
{ React.Children.map(this.props.children, (x) => {
// If the children is a falsy value (for IIFE in the render method for example)
// It should just ignore it instead of throwing an exception.
return isClonable(x)
? React.cloneElement(x, {onPress: this.onSelect})
: false;
})}
</View>
</TouchableWithoutFeedback>
);
}
});
return MenuOptions;
};