跳转到内容

React 适配器

请参阅英文版本 — @xenolithengine/graph-react 适配器的完整 API: <XenolithGraph>, useEditor, useNodes / useEdges / useSelection / useViewport / useGraphJSON / useUndoRedo / useEditorEvent, 编辑器内组件 (<XenolithPanel>, <XenolithButton>, <XenolithControls>, <XenolithMiniMap>), 自定义 React widget 使用 reactWidget(Component), 通过 on* props 处理事件。

受控状态(提交时)

React Flow 迁移者:useNodesState() 提供受控三元组 —— nodes、edges、applyChanges、 setNodes —— 由提交时的 graph:changed 数组折叠而成(ADR 0006)。 与 React Flow 的一个刻意区别:位置在拖拽 COMMIT 时才到达,绝不逐帧 —— 拖拽期间 WebGL 渲染器持有状态,你的组件树保持静止。setNodes(next) 以一个撤销步应用差异;回声是幂等的。 Redux/Zustand 请直接使用纯 reducer reduceGraphChanges。