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] Ambiguous match found for serviceIdentifier: FlowRendererRegistry #42

Open
fabricioloupias opened this issue Mar 10, 2025 · 5 comments

Comments

@fabricioloupias
Copy link

I'm trying to implement this product in a next js project, I follow the documentation https://flowgram.ai/en/examples/fixed-layout/fixed-layout-simple.html and I'm getting
Uncaught Error: Ambiguous match found for serviceIdentifier: FlowRendererRegistry

Image

Is it a compatibility issue with next js? or is there something wrong with the library? I can't find a solution for the moment.

packages:

  • "next": "14.2.15"
  • "antd": "^5.24.2"
  • "@flowgram.ai/fixed-layout-editor": "0.1.12",
  • "@flowgram.ai/fixed-semi-materials": "0.1.12",
  • "@flowgram.ai/group-plugin": "0.1.12",
  • "@flowgram.ai/minimap-plugin": "0.1.12",
@fabricioloupias
Copy link
Author

For next js users i solved it using:

// next.config.mjs
nextConfig.reactStrictMode = false

It seems that the inversify library used internally fails in the nextjs environment when executed twice. It would also be nice to find a comprehensive solution as this is a patch.

@dragooncjw
Copy link
Collaborator

It looks like the issue is caused by multiple instances. We'll fix it on our end as well. Thanks for the feedback!

@dragooncjw
Copy link
Collaborator

This is caused by the double rendering in React Strict Mode. In our underlying code, we have an implementation similar to the following:

const randomNum = useMemo(() => {
  const num = Math.random();
  console.log('num', num);
  return num;
}, []);

useMemo(() => {
  console.log('randomNum', randomNum);
}, [randomNum]);

As a result, we can see that num prints two different values, while randomNum prints the same value.

Additionally, although React Strict Mode triggers repeated renders by default, the behavior is normal in the production environment.

@Theseven87
Copy link

Theseven87 commented Mar 14, 2025

我也出现这个问题了。但是我没有使用next.js。我只是在vite创建的react ts项目中想要实现自由布局的基础用法,但是运行后出现错误
Ambiguous match found for serviceIdentifier: FlowRendererRegistry

packages:
"@ant-design/icons": "^5.6.1",
"@flowgram.ai/free-layout-editor": "^0.1.13",
"@flowgram.ai/free-snap-plugin": "^0.1.13",
"@flowgram.ai/minimap-plugin": "^0.1.13",
"@tailwindcss/vite": "^4.0.0",
"antd": "^5.24.3",
"axios": "^1.8.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.3.0",
"tailwindcss": "^4.0.0"

我注释掉了StrictMode就好了

@xiamidaxia
Copy link
Collaborator

strictMode 目前有问题,会导致 useMemo 失效

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

4 participants