antvis/G6

[Bug]: JSX-styled GNode tutorial page does not work #6879

divq posted onGitHub

Describe the bug / 问题描述

https://g6.antv.vision/examples/element/custom-node/#react-g 这个页面的教程说让使用这样的代码引入GNode

import { ExtensionCategory, Graph, register } from '@antv/g6';
import { GNode, Group, Image, Rect, Text } from '@antv/g6-extension-react';

但是在本地报错

<img width="929" alt="Image" src="https://github.com/user-attachments/assets/90d08734-11de-4872-8a4a-af77684c22e5" />

<img width="998" alt="Image" src="https://github.com/user-attachments/assets/02c082eb-00b2-461d-8f46-6f3927ad1ed9" />

查看node_modules里面依赖的此包,里面并没有export这些东西出来:

<img width="1214" alt="Image" src="https://github.com/user-attachments/assets/9e3b3249-9cf9-42f5-9ca3-befc1b57bf14" />

package.json如下:

{
  "name": "testcombiningjsintoone",
  "version": "1.0.0",
  "main": "webpack.config.js",
  "scripts": {
    "build": "webpack",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@antv/g6": "latest",
    "@antv/g6-extension-react": "latest",
    "react": "18.1.0",
    "react-dom": "18.1.0"
  },
  "devDependencies": {
    "@antv/g6-react-node": "^1.4.8",
    "@babel/core": "^7.26.10",
    "@babel/preset-env": "^7.26.9",
    "@babel/preset-react": "^7.26.3",
    "@types/react": "^19.0.11",
    "babel-loader": "^10.0.0",
    "ts-loader": "^9.5.2",
    "typescript": "^5.8.2",
    "webpack": "^5.98.0",
    "webpack-cli": "^6.0.1"
  }
}

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

It seems that you are experiencing an issue with the JSX-styled GNode tutorial page for antvis/g6. The error occurs because the expected exports (GNode, Group, Image, Rect, Text) are not found in the @antv/g6-extension-react package.

Here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Package Version: Ensure that you are using the latest version of @antv/g6-extension-react. Sometimes, the documentation might refer to features available in a newer version.

  2. Verify Exports: Double-check the node_modules/@antv/g6-extension-react directory to see if the expected components are indeed missing. If they are, it might indicate an issue with the package version or a problem with the package itself.

  3. Consult Documentation: Revisit the official documentation or the tutorial page to see if there have been any updates or errata that address this issue.

  4. Community and Support: Consider reaching out to the community or support channels for antvis/g6. They might have more insights or workarounds for this issue.

  5. Alternative Imports: If the components are not available as expected, you might need to explore alternative ways to achieve the desired functionality, possibly by using other components or custom implementations.

If the issue persists, you may want to report it to the maintainers of the antvis/g6 repository for further assistance. Let me know if you need help with that or if there's anything else I can assist you with!

<details> <summary>🪧 Tips</summary> For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. </details>

posted by petercat-assistant[bot] about 1 month ago
posted by divq about 1 month ago

Fund this Issue

$0.00
Funded

Pull requests