logo

X6

  • Tutorials
  • API
  • Examples
  • Q&A
  • Change Log
  • Productsantv logo arrow
  • 3.x
  • Introduction
  • Quickstart
  • Basic
    • Graph
    • Nodes
    • Edges
    • Ports
    • Interaction
    • Events
    • Data Serialization
    • Animation
  • Intermediate
    • Connection Points
    • Tools
    • Group
    • React Nodes
    • Vue Nodes
    • Angular Nodes
    • HTML Nodes
  • Plugin
    • Graphic Transformations
    • Snapline
    • Clipboard
    • Keyboard
    • History
    • Selection Box
    • Scroller
    • Dnd
    • Mini Map
    • Stencil
    • Export
  • Upgrade to 3.x
  • Developer Tools

React Nodes

Previous
Group
Next
Vue Nodes

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library
WeaveFox-AI Coding Assistant

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference
weavefoxWeaveFox-AI Developer Community

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
weavefoxWeaveFox-AI Coding Assistant
© Copyright 2026 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

This chapter mainly introduces knowledge related to React nodes. By reading, you can learn

  • How to use React components to render node content
  • How to update node content

Rendering Nodes

We provide a standalone package @antv/x6-react-shape for rendering nodes with React.

Note

Version compatibility: X6 3.x must use x6-react-shape 3.x. Since 2.0.8, x6-react-shape supports React 18+ only; if your project uses React < 18, lock x6-react-shape to 2.0.8 and use X6 2.x.

import { register } from '@antv/x6-react-shape'
const NodeComponent = () => {
return (
<div className="react-node">
<Progress type="circle" percent={30} width={80} />
</div>
)
}
register({
shape: 'custom-basic-react-node',
width: 100,
height: 100,
component: NodeComponent,
})
graph.addNode({
shape: 'custom-basic-react-node',
x: 60,
y: 100,
})

Updating Nodes

Similar to HTML, register a node with an effect field—an array of the node’s props. When any listed prop changes, the React component re-renders.

register({
shape: 'custom-update-react-node',
width: 100,
height: 100,
effect: ['data'],
component: NodeComponent,
})
const node = graph.addNode({
shape: 'custom-update-react-node',
x: 60,
y: 100,
data: {
progress: 30,
},
})
setInterval(() => {
const { progress } = node.getData<{ progress: number }>()
node.setData({
progress: (progress + 10) % 100,
})
}, 1000)

Portal Mode

The approach above renders the component directly into the node’s DOM:

import { createRoot, Root } from 'react-dom/client'
const root = createRoot(container) // container is the node container
root.render(component)

This detaches the component from the normal React tree, so it cannot access external Context. Use Portal mode when you need access to app-level context.