Skip to content

Commit 28bb694

Browse files
Himanshu SatijaHimanshu Satija
authored andcommitted
identify last item
1 parent f0bb375 commit 28bb694

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Components/Widgets/List.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,21 @@ export default class ListNB extends NativeBaseComponent {
3030
return computeProps(this.props, defaultProps);
3131

3232
}
33+
34+
renderChildren() {
35+
var childrenArray = React.Children.toArray(this.props.children);
36+
37+
var lastElement = _.last(childrenArray);
38+
39+
var modLastElement = React.cloneElement(lastElement, computeProps(lastElement.props, {last: true}));
40+
41+
return _.concat(_.slice(childrenArray, 0, childrenArray.length - 1), modLastElement);
42+
}
3343

3444
render() {
3545
return(
3646
<View {...this.prepareRootProps()} >
37-
{this.props.children}
47+
{this.renderChildren()}
3848
</View>
3949
);
4050
}

0 commit comments

Comments
 (0)