unicef / react-org-chart

Component for displaying an org chart for a large organization. Supports lazy load and export.
https://unicef.github.io/react-org-chart/
246 stars 123 forks source link

Dependence on a div with id=root #23

Open kaichiangbain opened 3 years ago

kaichiangbain commented 3 years ago

Trying to wrap this into a Mendix pluggable widget (a React widget), then place multiple of them in a page.

Noticed the dependency src\chart\index.js ... const orgChart = document.getElementById('root')

Where "root" is hardcoded, thus I cannot have multiple of these in a single page - I cannot have multiple divs with the same Id.

Make this part of the props passed in?

Boris-Scharinger commented 3 years ago

Dear Kaichiangbain - very interest in this project. Can we collaborateon the Mendix version? Regards, Boris

kaichiangbain commented 3 years ago

Sure. I am using the Mendix low code platform (mendix.com), which allows for React pluggable widget (https://docs.mendix.com/howto/extensibility/pluggable-widgets). The widget needs to allow multiple instances of it on the same page/DOM. Mendix also takes control of the DOM, thus widgets cannot arbitrarily apply an ID easily.

Since I am referencing this chart as-is via dependency "@unicef/react-org-chart": "0.3.4", I am trying to fix the hardcoded "root" in the original code. If this fails, I may need to import source code into my widget and change as necessary - definitely not preferable.