Skip to content

Commit fa8dc1e

Browse files
committed
Merge branch 'master' into rnUpgrade
2 parents 27ecc5c + 113b0f3 commit fa8dc1e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.npmignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
example
2-
3-
node_modules
2+
flow-typed
3+
node_modules
4+
__snapshots__

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# react-native-nested-listview
22
Nested listview component for React native that it allows to create a listview that has N levels of nesting
33

4+
![platforms](https://img.shields.io/badge/platforms-Android%20%7C%20iOS-brightgreen.svg?style=flat-square)
5+
[![npm](https://img.shields.io/npm/v/react-native-nested-listview.svg?style=flat-square)](https://www.npmjs.com/package/react-native-nested-listview)
6+
[![github release](https://img.shields.io/github/release/fjmorant/react-native-nested-listview.svg?style=flat-square)](https://github.com/fjmorant/react-native-nested-listview/releases)
47

58
## Table of contents
69

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class NestedListView extends React.PureComponent<Props, State> {
1919
id: shortid.generate(),
2020
items: this.props.data
2121
? this.props.data.map((child: Node, index: number) =>
22-
this.generateIds(this.props.data[index]),
22+
this.generateIds(this.props.data[index])
2323
)
2424
: [],
2525
name: 'root',
@@ -40,7 +40,7 @@ export default class NestedListView extends React.PureComponent<Props, State> {
4040

4141
if (children) {
4242
node[childrenName] = children.map((child, index) =>
43-
this.generateIds(children[index]),
43+
this.generateIds(children[index])
4444
)
4545
}
4646

@@ -49,7 +49,15 @@ export default class NestedListView extends React.PureComponent<Props, State> {
4949
return node
5050
}
5151

52-
getChildrenName = (node: Node) => this.props.getChildrenName(node)
52+
getChildrenName = (node: Node) => {
53+
if (node.name === 'root') {
54+
return 'items'
55+
}
56+
57+
return this.props.getChildrenName
58+
? this.props.getChildrenName(node)
59+
: 'items'
60+
}
5361

5462
render = () => {
5563
if (!this.props.getChildrenName) {

0 commit comments

Comments
 (0)