antvis / Graphin

A React toolkit for graph visualization based on G6
https://graphin.antv.antgroup.com
MIT License
980 stars 263 forks source link

TypeError: Cannot read properties of undefined (reading 'manipulateBehaviors') at AbstractGraph.removeBehaviors (graph.js:588:1) #474

Closed Faker-lz closed 11 months ago

Faker-lz commented 1 year ago

Describe the bug

When I used the G6 Graph in react project, I got the error in @antv/g6-core/es/graph/graph.js

Your Example Website or App

https://github.com/Faker-lz/sbom

Steps to Reproduce the Bug or Issue

I found an error to the following code according to the browser's console:

  /**
   * 移除行为
   * @param {string | ModeOption | ModeType[]} behaviors 移除的行为
   * @param {string | string[]} modes 从指定的模式中移除
   * @return {Graph} Graph
   */
  AbstractGraph.prototype.removeBehaviors = function (behaviors, modes) {
    var modeController = this.get('modeController');
    modeController.manipulateBehaviors(behaviors, modes, false);
    return this;
  };

Expected behavior

Is there anyone who is having the same problem as me and I would like help

Screenshots or Videos

No response

Platform

Additional context

No response

janwirth commented 1 year ago

I'm experiencing the same problem. Did you find a solution @Faker-lz

Faker-lz commented 1 year ago

Yes, I just used

ReactDOM.render(  <React.StrictMode>
    <App />
</React.StrictMode>, document.getElementById('root'))

to replace the official demo code:

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

I think the error ascribes React's version.

gaomAndximi commented 1 year ago

At the beginning, the version of react18 was used, and now the version has been reduced to 16.13.1. Now no errors are shown.

bobony commented 1 year ago

I am also experiencing the same problem I am using react18.2.0. Any luck?

bobony commented 1 year ago

if anyone facing issue run your app without React.StrictMode it works

Zhuoda1 commented 11 months ago

if anyone facing issue run your app without React.StrictMode it works

Thanks! Problem fixed.

Yanyan-Wang commented 11 months ago

Duplicated to https://github.com/antvis/Graphin/issues/476