lukasbach / react-complex-tree

Unopinionated Accessible Tree Component with Multi-Select and Drag-And-Drop
https://rct.lukasbach.com
MIT License
944 stars 74 forks source link

useControlledTreeEnvironmentProps: don't use setTimeout #266

Closed dlech closed 1 year ago

dlech commented 1 year ago

Using setTimeout() to defer setting state in React causes issues with testing, particularly with @testing-library/react. It prints errors to the console that an action is not wrapped in act().

This reworks the code to avoid the defered state update.

Solves #TODO

@lukasbach

dlech commented 1 year ago

I'm sure this needs more testing but I did check that it does not regress the bug mentioned in https://github.com/lukasbach/react-complex-tree/issues/76#issue-1248751879.

lukasbach commented 1 year ago

Cool, thanks a lot! I'll merge if for now and do some testing on the deployment.