react-component / react-component/tree

"Cannot read property 'indexOf' of undefined" with set `defaultExpandParent={false}` & not setting `defaultExpandedKeys`

Open
#257 0 comments 0 reactions 0 assignees View on GitHub

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.

image

image
image

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.