G6 icon indicating copy to clipboard operation
G6 copied to clipboard

React GNodes are not re-rendered when node data changes

Open jakobert opened this issue 1 year ago • 2 comments

Describe the bug / 问题描述

If you use a React GNode renderer in a React project, the nodes are not re-rendered when the node data changes.

If node data is displayed in a GNode, it only renders once. After the data was updated, the node still shows the old data even though it was updated in the graph instance.

import { ExtensionCategory, Graph, register } from "@antv/g6";
import { GNode } from "@antv/g6-extension-react";
import CustomNodeRenderer from "./CustomNodeRenderer";

register(ExtensionCategory.NODE, "g", GNode);

const graph = new Graph({
      data,
      layout: {
        type: "circular",
      },
      node: {
        type: "g",
        style: {
          component: CustomNodeRenderer,
        },
      },
      behaviors: ["drag-canvas", "zoom-canvas", "drag-element"],
    });

// ...

// This does not trigger a re-render of the individual GNodes
graph.setData(updatedData);
graph.render();

The longer example for React can be found here: https://gist.github.com/jakobert/80b3f15c68f143a3a4343aacdcb62842

Reproduction link / 重现链接

https://gist.github.com/jakobert/80b3f15c68f143a3a4343aacdcb62842

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

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

Windows

Browser / 浏览器

Chrome

Additional context / 补充说明

No response

jakobert avatar Jul 26 '24 15:07 jakobert

We will confirm the problem soon

Aarebecca avatar Jul 30 '24 09:07 Aarebecca

I'm experiencing the same behavior!

gitfrosh avatar Aug 07 '24 15:08 gitfrosh

In the latest version, this issue has been resolved.

Aarebecca avatar Oct 24 '24 08:10 Aarebecca