react-flow-code-review

Review React Flow code for anti-patterns and performance issues.

75|9|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/anderskev/beagle --skill react-flow-code-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-flow-code-review
Source: https://github.com/anderskev/beagle/tree/main/skills/react-flow-code-review
Command: npx skills add https://github.com/anderskev/beagle --skill react-flow-code-review

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps ensure memoization, stable nodeTypes, and proper event handling when using @xyflow/react in graph UIs.

Core Features & Use Cases

  • Performance & Memo: Memoize custom nodes/edges and stabilize nodeTypes.
  • Callbacks & Handles: Use useCallback and safe Handle positions.
  • Provider Usage: Ensure ReactFlow is used within a proper provider.

Quick Start

Review a React Flow component setup and apply best practices for naming nodeTypes, memoization, and event handlers.

Frequently Asked Questions about react-flow-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I improve React Flow performance with memoization?

Memoization in React Flow involves wrapping custom nodes and edges with React.memo to prevent unnecessary re-renders, stabilizing nodeTypes outside the render function, and using useCallback for event handlers. This reduces re-renders when props haven't changed, improving performance in complex graphs.

Why should nodeTypes be defined outside the render function in React Flow?

Defining nodeTypes outside render ensures they maintain a stable reference across re-renders. If nodeTypes is recreated on each render, React Flow treats them as new types and re-initializes nodes, causing performance degradation and breaking memoization.

What's the best way to handle callbacks in React Flow components?

Use useCallback to memoize event handlers like onNodesChange and onEdgesChange. This prevents child nodes and edges from re-rendering when callback references change, maintaining performance in large graphs while ensuring proper event handling.

Do I need to wrap React Flow components in a provider?

Yes, React Flow (@xyflow/react) requires wrapping components in a ReactFlowProvider. This establishes the context required for graph state management, node/edge rendering, and internal event handling to function correctly.

How do immutable data updates affect React Flow rendering?

Immutable updates to nodes and edges—creating new arrays/objects rather than mutating existing ones—trigger proper React change detection. This ensures React Flow detects updates, re-renders correctly, and maintains graph state consistency without performance issues.

Can I use custom nodes and edges safely with TypeScript in React Flow?

Yes, custom nodes and edges work with TypeScript when properly typed and memoized. Define nodeTypes and edgeTypes with correct typing, wrap components with React.memo, and follow library conventions to maintain type safety and performance.