Skip to content

[tree view] RichTreeViewPro with lazy-loading doesn't re-render (update) when items change. #19409

@gentrith44belt

Description

@gentrith44belt

Steps to reproduce

Steps:

  1. Open this link to live example: (required)
  2. Click update button (it updates react query data cache)
  3. Observe, nothing happens.

Current behavior

On data source change, the tree is not re-rendered

Expected behavior

On data source change, it should update items

Context

I have this RichTreeViewPro component where I lazy-load items from backend (with react query). The problem is that I need to do updates (for root items) and show/hide them real time from the tree-view.

The problem is that when I change the data in the backend and refetch the root items, the treeview doesn't re-render.
Maybe this is expected behavior for performance issues, but I dont understand how is this supposed to work.
For example with Data Grid even for lazy loading you can refetch the data and it re renders, but in this example I cannot find a solution, except providing a key={treeViewKey} and updating it everytime the data changes (force re-render)

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: RichTreeViewPro, re-render

Order ID: 108277

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: tree viewChanges related to the tree view. This includes TreeView, TreeItem.support: pro standardSupport request from a Pro standard plan user. https://mui.com/legal/technical-support-sla.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions