Skip to content

expand/collapse all nodes with useTreeState #3730

Answered by snowystinger
lienas asked this question in Q&A
Discussion options

You must be logged in to vote

If I recall correctly, state.collection will only have the "visible" keys since it's a collection and could theoretically have a lot of nodes, far more than you'd want rendered, non-visible nodes aren't included in the collection until their parents are expanded. You could add all the keys to the expanded keys set though and pass that in as a prop to useTreeState, thereby controlling the expanded states. You could also use defaultExpanded if you didn't want to make it controlled.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@lienas
Comment options

@snowystinger
Comment options

@lienas
Comment options

Answer selected by lienas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants