Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you avoid rendering first tree node #68

Open
chrisrzhou opened this issue Apr 17, 2018 · 1 comment
Open

How do you avoid rendering first tree node #68

chrisrzhou opened this issue Apr 17, 2018 · 1 comment

Comments

@chrisrzhou
Copy link

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!

@wrobbinz
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants