Pure render for tree data, fixes React Canary useMemo/useState StrictMode (#5835)
* Pure render for useTreeData
* adjust some more calls
* fix accumulation of build trees
* better readability
* fix typo
* fix remaining broken tests
* revert canary testing changes
* fix lint
* updating naming and making things a bit easier to read
* make sure a new map is always generated in insert for purity
* make useTreeData always use and return a new Map
this avoids the case where we may inadvertantly modify the previous map directly which could be problematic in a double render
* guard against empy array in remove
---------
Co-authored-by: Daniel Lu <dl1644@gmail.com>