forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListBody.tsx
30 lines (27 loc) · 882 Bytes
/
ListBody.tsx
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
import * as React from 'react';
import { View } from 'react-native';
import assign from 'object-assign';
import theme from './style/index';
import { ListBodyProps } from './ListPropTypes';
const THEMES = theme.ThemesList;
function makeArray(array) {
return array.length == null ? [array] : array;
}
export default class Body extends React.Component<ListBodyProps, any> {
render() {
const {error, style, children} = this.props;
const childrenArray = makeArray(children);
return (<View {...this.props} style={[THEMES.Body,
error ? THEMES.Error.Body : {}, style]}>
{
childrenArray.map((item, index) => {
if (index === childrenArray.length - 1) {
return React.cloneElement(item, assign({}, item.props, {last: true, key: index}));
} else {
return item;
}
})
}
</View>);
}
}