Skip to content

Is there a way to hide a rootNode in the tree? #34

Answered by Lodin
shrirambalaji asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Shriram-Balaji. That's pretty possible with resize(0, true), you just need to add overflow: hidden to your Node host element and call resize on each height change (because toggle resets the height; btw, that looks like a bug).

Here you can see the example. I basically changed the Node component.

Changed Node component code
const Node: FC<VariableSizeNodeComponentProps<ExtendedData>> = ({
  height,
  data: {id, isLeaf, name, nestingLevel},
  isOpen,
  resize,
  style,
  toggle,
  treeData: itemSize,
}) => {
  const canOpen = height <= itemSize;
  const halfSize = itemSize / 2;

  const toggleNodeSize = useCallback(
    () => resize(canOpen ? height + halfSize : height - halfSize, true),

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PoojaMgr
Comment options

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

This discussion was converted from issue #34 on December 11, 2020 07:17.