Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit dbb61b8

Browse files
committed
Calculate shouldExpandNode on JSONNestedNode.render
1 parent fa35d0a commit dbb61b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/JSONNestedNode.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ export default class JSONNestedNode extends React.Component {
114114
labelRenderer,
115115
expandable
116116
} = this.props;
117-
const expanded = this.state.expanded;
117+
let expanded = this.state.expanded;
118+
if (this.state.expanded === false) {
119+
expanded = this.props.shouldExpandNode && !this.props.isCircular ?
120+
this.props.shouldExpandNode(this.props.keyPath, this.props.data, this.props.level) :
121+
false;
122+
}
118123
const renderedChildren = expanded || (hideRoot && this.props.level === 0) ?
119124
renderChildNodes({ ...this.props, level: this.props.level + 1 }) : null;
120125

0 commit comments

Comments
 (0)