-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathRow.js
More file actions
54 lines (47 loc) · 1.1 KB
/
Row.js
File metadata and controls
54 lines (47 loc) · 1.1 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, {Component} from 'react';
import {View, TouchableOpacity} from 'react-native';
import computeProps from '../Utils/computeProps';
export default class RowNB extends Component {
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps);
}
props: {
style: Object,
size: number,
children: Object,
onPress: Function
};
prepareRootProps() {
const flex = (this.props.style && this.props.style.height) ? 0 : 1;
const defaultProps = {
style: {
flexDirection: 'row',
flex: this.props.size ? this.props.size : flex
}
};
return computeProps(this.props, defaultProps);
}
renderView() {
return (
<View
ref={(component) => {
this._root = component;
}}
{...this.props}
{...this.prepareRootProps()}
>
{this.props.children}
</View>
);
}
render() {
if (this.props.onPress) {
return (
<TouchableOpacity onPress={this.props.onPress}>
{this.renderView()}
</TouchableOpacity>
);
}
return this.renderView();
}
}