OrgChart icon indicating copy to clipboard operation
OrgChart copied to clipboard

Uncaught TypeError with React

Open abiodunsulaiman694 opened this issue 8 years ago • 4 comments

How do I use this with React? I was getting the error:

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_8_orgchart___default.a is not a constructor with the following:

`import React, { Component } from 'react'; import OrgChart from 'orgchart';

class Configuration extends Component{ constructor(props){ super(props); this.state = { currency: null }; } render(){ let datasource = { 'name': 'Lao Lao', 'title': 'general manager', 'children': [ { 'name': 'Bo Miao', 'title': 'department manager' }, { 'name': 'Su Miao', 'title': 'department manager', 'children': [ { 'name': 'Tie Hua', 'title': 'senior engineer' }, { 'name': 'Hei Hei', 'title': 'senior engineer', 'children': [ { 'name': 'Pang Pang', 'title': 'engineer' }, { 'name': 'Xiang Xiang', 'title': 'UE engineer' } ] } ] }, { 'name': 'Yu Jie', 'title': 'department manager' }, { 'name': 'Yu Li', 'title': 'department manager' }, { 'name': 'Hong Miao', 'title': 'department manager' }, { 'name': 'Yu Wei', 'title': 'department manager' }, { 'name': 'Chun Miao', 'title': 'department manager' }, { 'name': 'Yu Tie', 'title': 'department manager' } ] }, orgchart = new OrgChart({ 'chartContainer': '#chart-container', 'data' : datasource, 'depth': 2, 'nodeContent': 'title' }); return (

        </div>
    );
}

}

export default Configuration; `

Sorry about my markdown formatting

abiodunsulaiman694 avatar Jan 19 '18 06:01 abiodunsulaiman694

Hi @abiodunsulaiman694 , feel free to play around this Demo on codepen.io. Hope it's hopeful for you 😊

dabeng avatar Jan 22 '18 06:01 dabeng

@dabeng. Thanks so much. The error is cleared now, but for some reason, my style does not seem to work. I uploaded the snapshot below. Thanks.

image

abiodunsulaiman694 avatar Jan 22 '18 19:01 abiodunsulaiman694

Thanks @dabeng I fixed it by requiring the css from my index.js root file. Thank you

abiodunsulaiman694 avatar Jan 22 '18 20:01 abiodunsulaiman694

Thanks @dabeng I fixed it by requiring the css from my index.js root file. Thank you

What file did you require?

sammysamx20 avatar Jul 24 '19 21:07 sammysamx20