@antv/g6-extension-react
TypeScript icon, indicating that this package has built-in type declarations

0.1.17 • Public • Published

React extension for G6

This extension allows you to define G6 node by React component and JSX syntax.

Usage

  1. Install
npm install @antv/g6-extension-react
  1. Import and Register
import { ExtensionCategory, register } from '@antv/g6';
import { ReactNode, GNode } from '@antv/g6-extension-react';

register(ExtensionCategory.NODE, 'react', ReactNode);
register(ExtensionCategory.NODE, 'g', GNode);
  1. 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>
};
  1. 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

  1. Difference between ReactNode and GNode

ReactNode is a React component, while GNode support jsx syntax but can only use G tag node.

Resources

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.172,561latest
0.1.12-beta.12beta

Version History

VersionDownloads (Last 7 Days)Published
0.1.172,561
0.1.16654
0.1.151,543
0.1.141,540
0.1.13539
0.1.12-beta.12
0.1.123
0.1.111
0.1.10858
0.1.953
0.1.81,366
0.1.71,157
0.1.61
0.1.54
0.1.41
0.1.35
0.1.223
0.1.13
0.1.03
0.0.13

Package Sidebar

Install

npm i @antv/g6-extension-react

Weekly Downloads

8,342

Version

0.1.17

License

MIT

Unpacked Size

1.88 MB

Total Files

68

Last publish

Collaborators

  • lvisei
  • freestyle21
  • soundquiet
  • elaine.q.10
  • sturuby
  • sakuya223
  • serializedowen
  • xdzhao
  • yangzhanmei
  • wjgogogo
  • leungwensen
  • dori
  • iaaron
  • yard
  • simaq
  • dxq613
  • intchous
  • susan_ann
  • jinke.li
  • lzxue
  • army8735
  • atool
  • baizn
  • dengfuping
  • neoddish
  • jeffy2012
  • zqlu
  • afc163
  • pomelo-nwu
  • kopiluwaky
  • ccnuzindex
  • panyuqi
  • bubkoo
  • zengyue
  • kasmine
  • boyu.zlj
  • l1ud0ngq1
  • newbyvector
  • winniexing
  • chenluli
  • kn9117
  • xdddst
  • semious2020
  • esora
  • nadia_liu
  • bbsqq
  • mxz96102
  • openwayne
  • pearmini
  • pddpd
  • yiqianyao
  • zhanba
  • cxxxxxn
  • laixingui.lxg
  • susiwen8
  • yanxiong
  • zeyuwang
  • rainy25ghz
  • zhangjunjie-loki
  • flash1
  • yisi.wang
  • dreammy23
  • biupiubiupiu
  • basketduck
  • xuying1027
  • banxuan