react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Error with multiple trees

Open lightsinthesky opened this issue 1 year ago • 1 comments

If you have 2 Tree components rendering at the same time a React Maximum update depth exceeded error is thrown. The line below is causing the error.

useLayoutEffect(() => {
    // @ts-ignore
    dispatch(actions.setVisibleIds(api.visibleIds, api.idToIndex));  // <- causes the error.
  }, [dispatch, api.visibleIds, api.idToIndex, props.root]);

Here is a codesandbox with a basic repro.

https://codesandbox.io/s/react-arborist-forked-xb7ezj

Thanks!

lightsinthesky avatar Oct 05 '22 12:10 lightsinthesky

Oh, interesting. Thanks for repro. This will get looked into.

jameskerr avatar Oct 07 '22 19:10 jameskerr

This is solved by https://github.com/brimdata/react-arborist/pull/49 as the tree nodes is now an array.

mooijtech avatar Oct 20 '22 20:10 mooijtech

Great to hear that!

jameskerr avatar Oct 20 '22 22:10 jameskerr