Open
Description
I have 5000 nodes in a tree. Only 2 level, with about 5 "directories" and the rest being "files".
I'm using search by index, using such a simple function:
export function searchById({ node, path, treeIndex, searchQuery }) {
return node.id === searchQuery
}
React Sortable Tree is very unreliable on such data.
- It works 80% of the time, but it doesn't work on 20% of the time.
- By force-swapping the searchFocusOffset to null and 0 again it works, especially if I put it in a setTimeout
- Sometimes this causes 100% CPU use which doesn't stop as well as 1.2 GB of memory usage for the tab in Chrome's Task Manager.
My implementation is like this:
searchMethod={searchById}
searchQuery={searchQuery}
searchFinishCallback={matches => {
if (matches.length !== 1) return
window.setTimeout(() => {
mapUIStore.setSearchFocusOffset(null)
mapUIStore.setSearchFocusOffset(0)
}, 0)
}}
Note: I'm using my own handling of collapsing / expanding "folder" nodes, with a dummyonChange={() => {}}
, that's why I probably need the setTimeout.
Still the CPU and memory usage shouldn't happen.
// Because of this, I'm migrating my app to react-sortable-hoc, so I actually don't need this to be solved, I just wanted to report it.