Skip to content

All UITreeNode re-rendered when expanding/collapsing nodes #8542

@glatuske

Description

@glatuske

Describe the bug

When expanding or collapsing nodes (also selecting etc.) nodes in the basic tree demo (https://primereact.org/tree/#basic) new UITreeNode will be created even for nodes which are not expanded/collapsed.

This is no problem for small trees, but adds significant rendering time in case of larger trees (e.g. 1000 root nodes).

Reproducer

https://stackblitz.com/edit/z6evqupr?file=src%2FApp.jsx

System Information

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1270P
    Memory: 9.90 GB / 31.70 GB
  Binaries:
    Node: 24.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - C:\Users\lgr9fe\AppData\Roaming\npm\yarn.CMD
    npm: 11.6.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 148.0.7778.179
    Edge: Chromium (144.0.3719.92)
    Firefox: 140.11.0 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.26100.8115
  npmPackages:
    primereact: latest => 10.9.8 
    react: 18.3.1 => 18.3.1

Steps to reproduce the behavior

  1. Run Lazy Tree demo https://primereact.org/tree/#lazy
  2. Observe new UITreeNode will be created for Node 0 when expanding Node 1

Expected behavior

UITreeNode should be only re-created / re-rendered if necessary (children expanded/collapsed, label changed, ...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions