react-flow-code-review
Skill91 starsChanged 4 days agoApache-2.0View on GitHub
Reviews React Flow (@xyflow/react v12/v13) code for anti-patterns, re-render traps, SSR/measurement bugs, layout coordinate errors, and API deprecations. Use when reviewing node-based UI code or auditing @xyflow/react implementations.
In this repository85 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- agent-architecture-analysisSkill
- app-intents-code-reviewSkill
- artifact-analysisSkill
- axum-code-reviewSkill
- brainstorm-beagleSkill
- bubbletea-code-reviewSkill
- cloudkit-code-reviewSkill
- elixir-performance-reviewSkill
- elixir-security-reviewSkill
- elixir-writing-docsSkill
- exdoc-configSkill
- exunit-code-reviewSkill
- fastapi-code-reviewSkill
- fetch-pr-feedbackSkill
- ffi-code-reviewSkill
- fix-llm-artifactsSkill
- fowler-refactoringSkill
- gen-test-planSkill
- go-architectSkill
- go-code-reviewSkill
- go-data-persistenceSkill
- go-testing-code-reviewSkill
- healthkit-code-reviewSkill
- humanize-beagleSkill
- improve-docSkill
- ios-animation-code-reviewSkill
- liveview-code-reviewSkill
- llm-artifacts-detectionSkill
- llm-judgeSkill
- macros-code-reviewSkill
- phoenix-code-reviewSkill
- postgres-code-reviewSkill
- prfaq-beagleSkill
- prometheus-go-code-reviewSkill
- pytest-code-reviewSkill
- quick-planSkill
- react-flowSkill
- react-router-code-reviewSkill
- react-router-v7Skill
- receive-feedbackSkill
- refactor-repoSkill
- resolve-beagleSkill
- respond-pr-feedbackSkill
- review-ai-writingSkill
- review-elixirSkill
- review-frontendSkill
- review-goSkill
- review-iosSkill
- review-llm-artifactsSkill
- review-planSkill
- review-pythonSkill
- review-remix-v2Skill
- review-rustSkill
- review-skillSkill
- review-structureSkill
- review-tuiSkill
- review-verification-protocolSkill
- run-test-planSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
When reviewing React Flow (@xyflow/react v12/v13) code, complete the gates below in order.
- Very specific: line 46
Fix: Use useNodesData(id | ids) for specific node data, useNodeConnections(...) for handle connections, or targeted store selectors …
≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Flow Code Review
When reviewing React Flow (@xyflow/react v12/v13) code, complete the gates below in order. Each step has an objective pass condition before moving on.
Review Gates (Sequenced)
- Locate flow code — Search the review scope for
@xyflow/react,ReactFlow,ReactFlowProvider,useReactFlow,nodeTypes,edgeTypes, and@dagrejs/dagre. Pass: a list of file paths (or explicit "none in scope"). - Provider & container boundary — For each
useReactFlow(),useNodesData(),useNodeConnections(), or store hook, trace the component tree to an enclosing<ReactFlowProvider>(or<ReactFlow />). Confirm the flow wrapper has explicit height/width and styles are imported. Pass: provider + container verified or concrete mismatch cited with file:line. - Stable types, memoization & subscriptions — Confirm
nodeTypes/edgeTypesare defined outside render or memoized, custom nodes/edges usememo()and typedNodeProps<T>/EdgeProps<T>, and components avoid subscribing to fullnodes/edgesarrays when targeted hooks suffice. Pass: stability and subscriptions verified or traps cited with file:line. - Report with evidence — For each finding you deliver, record file path and line number(s) (plus a minimal quoted snippet). Pass: no critical or high-severity issue is stated without that citation.
- Close the checklists — Verify Critical Anti-Patterns, v12 / v13, SSR & Layout Checks, and Performance Checklist; mark each area satisfied, not applicable (with reason), or open with evidence.
Critical Anti-Patterns
1. Defining nodeTypes / edgeTypes Inside Components
Recreates the object reference on every render, causing React Flow to unmount and remount every node/edge.
// BAD - recreates object every render
function Flow() {
const nodeTypes = { custom: CustomNode };
return <ReactFlow nodeTypes={nodeTypes} />;
}
// GOOD - module scope (or useMemo with stable deps)
const nodeTypes = { custom: CustomNode };
function Flow() {
return <ReactFlow nodeTypes={nodeTypes} />;
}2. Missing memo() on Custom Nodes / Edges
Without memo(), panning/selecting or updating one node triggers unnecessary re-renders across every custom node/edge.
3. Subscribing to Full nodes / edges in Nodes, Edges, or Toolbars (useNodes() Trap)
Calling useNodes(), useEdges(), or subscribing to state.nodes inside a custom node/edge or status bar re-renders that component on every drag tick.
- Fix: Use
useNodesData(id | ids)for specific node data,useNodeConnections(...)for handle connections, or targeted store selectors (useStore(selector, shallow)in v12; split storesuseNodesStore/useEdgesStore+useShallowin v13).
4. Using useReactFlow() Outside ReactFlowProvider
Calling useReactFlow() in the same component that renders <ReactFlow> without an enclosing <ReactFlowProvider> throws a missing-provider runtime error. Wrap the parent in <ReactFlowProvider> or move the hook into a child component.
5. Full-Array Cloning vs updateNodeData & Direct Mutation
- Direct mutation (
nodes[0].position = ...; setNodes(nodes)) breaks React Flow's reference checks and fails to update. - Full-array mapping for data updates causes unnecessary churn; prefer
useReactFlow().updateNodeData(id, partialOrUpdater)(orupdateEdgeData) for data-only updates. - Inline callbacks: Wrap
onNodesChange,onEdgesChange,onConnect, andisValidConnectioninuseCallbackwith functionalsetNodes((nds) => ...)/setEdges((eds) => ...).
v12 / v13, SSR & Layout Checks
Flag these concrete bugs when present:
| Issue | What to Look For | Correct Pattern |
| Missing CSS or Tailwind v4 layer clash | No @xyflow/react/style.css (v13) or @xyflow/react/dist/style.css (v12) import; unlayered CSS overriding Tailwind utilities | Import @xyflow/react/style.css (wrapped in @layer xyflow in v13) or @xyflow/react/dist/style.css (v12) |
| Missing container dimensions | <ReactFlow /> inside a height: auto or flex parent with no explicit height | Explicit width & height (e.g., h-screen w-full or style={{ width: '100%', height: '100%' }}) |
| SSR / SSG missing node dimensions | Server-rendered flow relies on fitView or layout without static dimensions | Provide static width/height or initialWidth/initialHeight on nodes for SSR/SSG |
Bare node.width for measured nodes | Reading node.width / node.height after render instead of DOM-measured dimensions | Use node.measured?.width ?? node.width ?? defaultWidth |
| Dynamic handles + stale measurement | Calling updateNodeInternals(id) synchronously inside onClick (before React commits), or passing args to useUpdateNodeInternals(id) | const updateNodeInternals = useUpdateNodeInternals(); (no args), called inside useEffect after handle count/IDs change |
| Missing interaction classes | <input>, <button>, <select>, or scrollable containers inside custom nodes or EdgeLabelRenderer lacking nodrag / nopan / nowheel / nokey | Add nodrag (and nopan/nowheel/nokey as appropriate); EdgeLabelRenderer overlays also need pointerEvents: 'all' |
| String literal handle positions | <Handle position="right" /> | Use Position.Right enum from @xyflow/react |
| Sub-flow ordering (v12) | Child node with parentId placed before its parent node in nodes[] on @xyflow/react v12 | Place parent before children in v12 (relaxed in v13) |
| Dagre package & coordinate bug | Importing unmaintained legacy dagre package instead of @dagrejs/dagre, missing - width/2, - height/2 center-to-top-left offset, or not excluding group nodes | Use @dagrejs/dagre, subtract half-dimensions matching g.setNode, exclude group nodes, and defer fitView to requestAnimationFrame |
| v13 removed / changed APIs | Calling removed useHandleConnections / getHandleConnections or v11 updateEdge utility; monolithic useStore on v13; isValidConnection typed without Connection | Edge | Use useNodeConnections / getNodeConnections, reconnectEdge, v13 split stores (useNodesStore, etc. with useShallow), and Connection | Edge |
Wrong CSSProperties import | Importing CSSProperties from '@xyflow/react' | Import CSSProperties from 'react' |
Performance Checklist
- Custom nodes and custom edges wrapped in
memo() nodeTypesandedgeTypesdefined at module scope or memoized withuseMemo- No
useNodes()/useEdges()inside custom nodes/edges (useuseNodesData/useNodeConnections/ targeted selectors) - Functional state updates (
setNodes((nds) => ...)) andupdateNodeDatafor data-only updates onlyRenderVisibleElements={true}considered for graphs > 100 nodesfitViewnot called on every render; post-layoutfitViewdeferred viarequestAnimationFrame/useNodesInitialized- TypeScript unions use
BuiltInNode | CustomNode,NodeProps<CustomNode>,EdgeProps<CustomEdge>, anduseNodesState<AppNode>
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

