Skip to content

[WC-3163] Treenode v2#2166

Open
gjulivan wants to merge 3 commits intomainfrom
treenodeV2
Open

[WC-3163] Treenode v2#2166
gjulivan wants to merge 3 commits intomainfrom
treenodeV2

Conversation

@gjulivan
Copy link
Copy Markdown
Collaborator

@gjulivan gjulivan commented Apr 8, 2026

Pull request type


Description

@gjulivan gjulivan requested a review from a team as a code owner April 8, 2026 09:02
@gjulivan gjulivan changed the title Treenode v2 [WC-3163] Treenode v2 Apr 9, 2026
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs bit of refactoring.

  • We need extract all logic (useEffect) to function, so we can test it.
  • We should create new type for tree, something like TreeState that should replace multiple useRefs
  • Line 26 -> let's use type literlas

Also, how we prevent recursion?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we need extract logic to function so we can write unit tests

(node: TreeNodeV2DataItem) => {
if (node.treeNodeState === TreeNodeState.EXPANDED) {
node.treeNodeState = TreeNodeState.COLLAPSED_WITH_CSS;
forceRender(version => version + 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forceRender uses useReducer with default n => n + 1 reducer. This removes need to always pass function to forceRender

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants