Skip to content

Commit 2637175

Browse files
Kulgarmrchief
andauthored
fix(compilation): Fixing the searchModeOn compilation problem (#482)
Co-authored-by: Hrusikesh Panda <[email protected]>
1 parent d22f809 commit 2637175

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/tree/index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ import React, { Component } from 'react'
55
import TreeNode from '../tree-node'
66
import { findIndex } from '../utils'
77

8-
const shouldRenderNode = (node, searchModeOn, data) => {
9-
if (searchModeOn || node.expanded) return true
10-
11-
const parent = node._parent && data.get(node._parent)
12-
// if it has a parent, then check parent's state.
13-
// otherwise root nodes are always rendered
14-
return !parent || parent.expanded
15-
}
16-
178
class Tree extends Component {
189
static propTypes = {
1910
data: PropTypes.object,
@@ -68,6 +59,17 @@ class Tree extends Component {
6859
}
6960
}
7061

62+
shouldRenderNode = (node, props) => {
63+
const { data, searchModeOn } = props
64+
const { expanded, _parent } = node
65+
if (searchModeOn || expanded) return true
66+
67+
const parent = _parent && data.get(_parent)
68+
// if it has a parent, then check parent's state.
69+
// otherwise root nodes are always rendered
70+
return !parent || parent.expanded
71+
}
72+
7173
getNodes = props => {
7274
const {
7375
data,
@@ -86,7 +88,7 @@ class Tree extends Component {
8688
} = props
8789
const items = []
8890
data.forEach(node => {
89-
if (shouldRenderNode(node, searchModeOn, data)) {
91+
if (this.shouldRenderNode(node, props)) {
9092
items.push(
9193
<TreeNode
9294
keepTreeOnSearch={keepTreeOnSearch}

0 commit comments

Comments
 (0)