Skip to content

Commit 5bfb9e9

Browse files
author
Javier Morant
authored
Merge pull request #12 from fjmorant/nodeStateInRenderNode
Be able to receive whether the node received in renderNode is opened or not
2 parents 40afce4 + a0d4595 commit 5bfb9e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+425
-2196
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
example
1+
examples
22
flow-typed
33
node_modules
44
__snapshots__

NodeView.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export default class NodeView extends React.PureComponent<Props, State> {
2929

3030
componentWillMount = () => {
3131
this.setState({
32-
node: this.props.node,
32+
node: {
33+
opened: false,
34+
...this.props.node,
35+
},
3336
})
3437
}
3538

@@ -56,6 +59,8 @@ export default class NodeView extends React.PureComponent<Props, State> {
5659
)
5760
}
5861

62+
renderItem = ({item}) => this.renderChildren(item, this.props.level)
63+
5964
render() {
6065
const rootChildrenName = this.props.getChildrenName(this.state.node)
6166
const rootChildren = this.state.node[rootChildrenName]
@@ -70,7 +75,7 @@ export default class NodeView extends React.PureComponent<Props, State> {
7075
{this.state.node.opened && rootChildren ? (
7176
<FlatList
7277
data={rootChildren}
73-
renderItem={({item}) => this.renderChildren(item, this.props.level)}
78+
renderItem={this.renderItem}
7479
keyExtractor={item => item.id}
7580
/>
7681
) : null}

example/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)