0.2.3 • Published 6 months ago
@antv/g6-extension-react v0.2.3
React extension for G6
This extension allows you to define G6 node by React component and JSX syntax.
Usage
- Install
npm install @antv/g6-extension-react- Import and Register
import { ExtensionCategory, register } from '@antv/g6';
import { ReactNode } from '@antv/g6-extension-react';
register(ExtensionCategory.NODE, 'react', ReactNode);- Define Node
React Node:
const ReactNode = () => {
return <div>node</div>;
};G Node:
import { Group, Rect, Text } from '@antv/g6-extension-react';
const GNode = () => {
return <Group>
<Rect width={100} height={100}></Rect>
<Text text={"node"} />
<Group>
};- Use
Use ReactNode:
const graph = new Graph({
// ... other options
node: {
type: 'react',
style: {
component: () => <ReactNode />,
},
},
});Use GNode:
const graph = new Graph({
// ... other options
node: {
type: 'g',
style: {
component: () => <GNode />,
},
},
});Q&A
- Difference between ReactNode and GNode
ReactNode is a React component, while GNode support jsx syntax but can only use G tag node.
Resources
0.1.10
11 months ago
0.1.11
11 months ago
0.1.12
11 months ago
0.1.13
11 months ago
0.1.14
11 months ago
0.1.15
10 months ago
0.1.12-beta.1
11 months ago
0.2.1
7 months ago
0.2.0
8 months ago
0.1.16
10 months ago
0.1.8
12 months ago
0.1.17
10 months ago
0.1.18
9 months ago
0.1.19
8 months ago
0.1.9
11 months ago
0.2.3
6 months ago
0.2.2
6 months ago
0.1.7
1 year ago
0.1.6
1 year ago
0.1.5
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.0
1 year ago
0.0.1
1 year ago