react-flow-advanced
Advanced React Flow patterns for complex use cases. Use when implementing sub-flows, custom connection lines, programmatic layouts, drag-and-drop, undo/redo, or complex state synchronization.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/anderskev/react-flow-advancedAdvanced React Flow Patterns
Gates (check before shipping)
Use these as sequenced checks—not “I think it works.”
- Sub-flows / groups: Pass: Every
parentIdmatches an existing nodeid; the parenttypeis registered innodeTypes; child positions are relative to the parent as intended (spot-check one drag inside/outside the group). - Custom connection line: Pass: With a valid/invalid drag, stroke or
connectionStatusvisibly differs; path renders without console errors fromgetSmoothStepPath(invalid coords). - External drag-and-drop: Pass:
onDragOveralwayspreventDefault(); drop position usesscreenToFlowPosition(not rawclientX/clientYas flow coords); new node appears under the cursor on the pane. - Undo/redo: Pass: One undo returns to the prior
{ nodes, edges }; redo restores; rapid changes do not leavecanUndo/canRedoinconsistent with visible graph (exercise add → undo → redo once). - Programmatic layout (dagre): Pass: After
setNodes, node positions match intendedrankdir;fitViewruns after layout (e.g.requestAnimationFrame) so the viewport is not stale. - Connect on drop (new node): Pass: Dropping on empty pane creates a node and an edge from the source handle; dropping on a valid target does not duplicate nodes (only the invalid-drop path adds a node).
- Selectors / store: Pass: Components that
useStorewith objects useshallow(or equivalent) so unrelated store updates do not re-render every frame.
Sub-Flows (Nested Nodes)
const nodes = [
// Parent (group) node
{
id: 'group-1',
type: 'group',
position: { x: 0, y: 0 },
style: { width: 400, height: 300, padding: 10 },
data: { label: 'Group' },
},
// Child nodes
{
id: 'child-1',
parentId: 'group-1', // Reference parent
extent: 'parent', // Constrain to parent bounds
expandParent: true, // Auto-expand parent if dragged to edge
position: { x: 20, y: 50 }, // Relative to parent
data: { label: 'Child 1' },
},
{
id: 'child-2',
parentId: 'group-1',
extent: 'parent',
position: { x: 200, y: 50 },
data: { label: 'Child 2' },
},
];
Group Node Component
function GroupNode({ data, id }: NodeProps) {
return (
<div className="group-node">
<div className="group-header">{data.label}</div>
{/* Children are rendered automatically by React Flow */}
</div>
);
}
Custom Connection Line
import { ConnectionLineComponentProps, getSmoothStepPath } from '@xyflow/react';
function CustomConnectionLine({
fromX, fromY, fromPosition,
toX, toY, toPosition,
connectionStatus,
}: ConnectionLineComponentProps) {
const [path] = getSmoothStepPath({
sourceX: fromX,
sourceY: fromY,
sourcePosition: fromPosition,
targetX: toX,
targetY: toY,
targetPosition: toPosition,
});
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-anderskev-react-flow-advanced": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
explanation-docs
Explanation documentation patterns for understanding-oriented content - conceptual guides that explain why things work the way they do
tutorial-docs
Tutorial patterns for documentation - learning-oriented guides that teach through guided doing
pytest-code-review
Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns.
reference-docs
Reference documentation patterns for API and symbol documentation. Use when writing reference docs, API docs, parameter tables, or technical specifications. Triggers on reference docs, API reference, function reference, parameters table, symbol documentation.
serde-code-review
Reviews serde serialization code for derive patterns, enum representations, custom implementations, and common serialization bugs. Use when reviewing Rust code that uses serde, serde_json, toml, or any serde-based serialization format. Covers attribute macros, field renaming, and format-specific pitfalls.