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

demo unavailable #9

Closed
Alt-er opened this issue Dec 20, 2019 · 2 comments
Closed

demo unavailable #9

Alt-er opened this issue Dec 20, 2019 · 2 comments

Comments

@Alt-er
Copy link

Alt-er commented Dec 20, 2019

demo

@Lodin
Copy link
Owner

Lodin commented Dec 20, 2019

You haven't specified the style for the root div in the Node component. You have the following code:

const Node = ({ data: { isLeaf, name }, isOpen, style, toggle }) => (
  <div style={style}>
    {!isLeaf && (
      <button type="button" onClick={toggle}>
        {isOpen ? "-" : "+"}
      </button>
    )}
    <div>{name}</div>
  </div>
);

To make it working, you should change it in the following way:

const Node = ({ data: { isLeaf, name, nestingLevel }, isOpen, style, toggle }) => (
  <div style={{
      ...style,
      alignItems: 'center',
      display: 'flex',
      marginLeft: nestingLevel * 30 + (isLeaf ? 48 : 0),
    }}>
    {!isLeaf && (
      <button type="button" onClick={toggle}>
        {isOpen ? "-" : "+"}
      </button>
    )}
    <div>{name}</div>
  </div>
);

You can also do it using CSS. Demo code uses the direct style assigning just because it is faster and easier to show the main approach.

@Lodin Lodin closed this as completed Dec 20, 2019
@Lodin
Copy link
Owner

Lodin commented Dec 20, 2019

If you have any further questions, feel free to reopen the issue!

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