react-ui-tree icon indicating copy to clipboard operation
react-ui-tree copied to clipboard

How do you avoid rendering first tree node

Open chrisrzhou opened this issue 6 years ago • 1 comments

Thank you so much for this wonderful library! I'm getting this to work really well for my use-case. I have one problem to ask:

Currently, tree requires an initial first node with children e.g.

rootFolder
  fileA.js
  fileB.js
  folderA
    fileC.js

I want to be able to just render the flat entries (excluding rootFolder)

fileA.js
fileB.js
folderA
  fileC.js

Here is my codesandbox.io: https://codesandbox.io/s/j35ynz58q9.

I tried to play around with data.js but I could not get it to work well for me. Please let me know what I have to do to get this working. Thank you!

chrisrzhou avatar Apr 17 '18 00:04 chrisrzhou

I found a workaround that is working for me.

By adding the below conditional near the top of render() method in node.js, the tree will avoid rendering the entire node and will simply render the children if it is the first tree node. This effectively skips rendering of the first node, but still renders its children.

render() {
  // const { tree, index, dragging } = this.props;
  if (index.id === 1) {
    return this.renderChildren();
  }

  return (
    <div...

wrobbinz avatar Jul 20 '18 07:07 wrobbinz