react-component / react-component/tree
"Cannot read property 'indexOf' of undefined" with set `defaultExpandParent={false}` & not setting `defaultExpandedKeys`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 490
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 5
Description
Tree.js?67c8:383 Uncaught TypeError: Cannot read property 'indexOf' of undefined Cannot read property 'indexOf' of undefined with no setting defaultExpandedKeys & set defaultExpandParent={false}
Here is my usage:
<DirectoryTree
showIcon
defaultExpandParent={false}
selectedKeys={this.state.selectedKeys}
onSelect={this.onTreeSelect}
>
{this.renderNewNodes2(this.state.treeData)}
</DirectoryTree>
The error occurs when the TreeNode is clicked.



But if I set defaultExpandedKeys={[]} by default, there is no error.
<DirectoryTree
showIcon
defaultExpandParent={false}
selectedKeys={this.state.selectedKeys}
onSelect={this.onTreeSelect}
defaultExpandedKeys={[]}
>
{this.renderNewNodes2(this.state.treeData)}
</DirectoryTree>
However, this usage is not be declared on the docs. Plz fix it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported DirectoryTree case with defaultExpandParent={false} and no defaultExpandedKeys, then inspect Tree.js around line 383 to trace the undefined value. Confirm the click no longer throws when defaultExpandedKeys is omitted, and verify the documented usage covers this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100