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

Error: TypeError: Cannot read property 'tree' of undefined #13

Open
Akrion opened this issue May 29, 2020 · 3 comments
Open

Error: TypeError: Cannot read property 'tree' of undefined #13

Akrion opened this issue May 29, 2020 · 3 comments

Comments

@Akrion
Copy link

Akrion commented May 29, 2020

I am trying to use this module in a project and with the provided demo tree I can not load the component at all. Issues I noticed are:

  • The clean install does not work since it seems we have a dependency on d3 which I had to install in addition to get the app off the ground.
  • From the documentation it is not very clear if the following properties are required:
    • onConfigChange
    • loadConfig
  • After the d3 install I am getting the error:
TypeError: Cannot read property 'tree' of undefined

My whole App.js is:

import React from 'react';
import './App.css';
import OrgChart from '@unicef/react-org-chart'

let tree = {
  id: 1,
  person: {
    id: 1,
    avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/spbroma/128.jpg',
    department: '',
    name: 'Jane Doe',
    title: 'CEO',
    totalReports: 1
  },
  hasChild: true,
  hasParent: false,
  isHighlight: true,
  children: [
    {
    id: 2,
    person: {
      id: 2,
      avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/spbroma/128.jpg',
      department: '',
      name: 'John Foo',
      title: 'CTO',
      totalReports: 0
    },
    hasChild: false,
    hasParent: true,
    isHighlight: false,
    children: []
  }]
}

function App() {
  return (
    <div className="App">
      <OrgChart tree={tree} />
    </div>
  );
}

export default App;

my-app.zip

@Akrion
Copy link
Author

Akrion commented May 30, 2020

I was able to make some progress on this by adding exactly the 3.5.17 d3 version to the package.json. D3 latest version is not compatible.

@itsnotme01
Copy link

Thank you, I had the same error and it solved it, did you found a way to display something?

@tdozi
Copy link

tdozi commented Oct 13, 2020

I believe this is related to layout method in d3: #11

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

3 participants