bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
927 stars 330 forks source link

Import issue #199

Closed huyongtao-cmd closed 1 year ago

huyongtao-cmd commented 2 years ago

Describe the bug 创建OrgChart实例会有警告,不能正常创建实例;d3引入也会报错,这是什么原因呢?

image image

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

mrinmays commented 2 years ago

Hi @huyongtao-cmd , sorry I'm seeing this a bit late, will leave a fix for someone visiting in the future.

On the top, chart declaration can be updated as follows.

const chart = useRef(null);

and inside the useLayoutEffect (+ everywhere else), usage would be updated to -

 if (!chart.current) {
    chart.current = new ChartRenderer();
}