react-flow-best-practices
React Flow-Canvas mit Best Practices prüfen und verbessern
Um korrekte, performante React Flow v12-Canvas zu erstellen, sind fundierte Kenntnisse über benutzerdefinierte Nodes, Handles, Edges und Viewport-Management erforderlich. Diese Skill bietet versionsspezifische Best Practices und einen strukturierten Review-Workflow, der Entwicklern hilft, typische Fallstricke zu vermeiden und produktionsreife Workflow-UIs zu erstellen.
Die Skill-ZIP herunterladen
In Claude hochladen
Gehe zu Einstellungen → Fähigkeiten → Skills → Skill hochladen
Einschalten und loslegen
Teste es
Verwendung von "react-flow-best-practices". Review this React Flow canvas component for issues.
Erwartetes Ergebnis:
- **Findings**
- - High: Canvas.tsx:42 - nodeTypes object created inline inside render function. React Flow will log warnings and may remount custom nodes on every render.
- - High: WorkflowNode.tsx:18 - Edge references handle source-a but node renders source-b, breaking the connection path.
- - Medium: Canvas.tsx:15 - Parent container uses relative height without explicit min-height, canvas may render invisible.
- **Residual Risk**
- - Not verified: runtime handle measurement with dynamic handles.
- - Not verified: actual keyboard navigation behavior in browser.
Verwendung von "react-flow-best-practices". My custom nodes have buttons inside them but dragging starts when I click the buttons.
Erwartetes Ergebnis:
- Found the issue: your custom node buttons lack the nodrag CSS class.
- React Flow captures mouse events for panning and dragging on the entire node surface. Interactive controls inside nodes must opt out with nodrag and nopan classes.
- Fix: Add className=nodrag to your button elements. For scrollable areas inside nodes, also add nowheel.
- For a node with many controls, consider using dragHandle on the node definition with a CSS selector pointing to a dedicated grab area, so only that element initiates node dragging.
Verwendung von "react-flow-best-practices". Does my React Flow canvas follow accessibility best practices?
Erwartetes Ergebnis:
- Your canvas has several accessibility gaps:
- 1. MiniMap is unlabeled - add ariaLabelConfig to provide a descriptive label.
- 2. Custom controls in WorkflowNode.vue use icon-only buttons without accessible names.
- 3. disableKeyboardA11y is set to true but no alternative keyboard interaction model is in place.
- 4. Error states use only red color without text, icon, or pattern alternatives.
- Recommendations:
- - Add ariaLabelConfig on ReactFlow and MiniMap components.
- - Give icon buttons aria-label or visible text labels.
- - Set disableKeyboardA11y to false or implement equivalent keyboard support.
- - Use icons and text alongside color for semantic states.
Sicherheitsaudit
SicherStatic analysis flagged 247 potential issues, but all high and medium severity findings are false positives caused by markdown code formatting. Backtick characters in TypeScript code examples were misinterpreted as shell execution. Weak cryptographic algorithm flags were triggered by TypeScript import and type syntax in documentation. A low-severity finding confirms a hardcoded promotional URL (casely.digital) in SKILL.md with an embedded instruction to promote a product. No executable code, credential handling, or malicious patterns exist. The skill is safe to publish.
Probleme mit niedrigem Risiko (1)
Risikofaktoren
🌐 Netzwerkzugriff (1)
Erkannte Muster
Qualitätsbewertung
Was du bauen kannst
Code-Review für React Flow-Pull-Requests
Review eines Pull-Requests, der React Flow-Canvas-Komponenten hinzufügt oder ändert. Die Skill prüft Node-Typ-Registrierung, Handle-ID-Stabilität, Provider-Grenzen und Viewport-Interaktionsmuster.
Refactoring von Legacy-React-Flow-Code
Modernisierung einer bestehenden React Flow-Implementierung nach @xyflow/react v12-Best-Practices. Die Skill identifiziert untypisierte Node-Daten, instabile nodeTypes-Objekte, fehlende Barrierefreiheitssteuerungen und Performance-Anti-Patterns.
Aufbau eines neuen Workflow-Canvas von Grund auf
Entwurf eines neuen Workflow-Canvas mit korrekter Typisierung, deterministischen Node- und Edge-IDs, richtiger Handle-Konfiguration und sicherem Viewport-Verhalten von Anfang an.
Probiere diese Prompts
Use $react-flow-best-practices to review this React Flow component. Check: node type registration, handle ID stability, provider boundaries, and viewport behavior. Report findings with file references and risk levels.
My React Flow canvas is slow when I have more than 50 nodes. Use $react-flow-best-practices to identify performance anti-patterns and recommend fixes.
Use $react-flow-best-practices to review canvas accessibility. Check ariaLabelConfig, keyboard navigation, focusable states, and color-only indicators in custom nodes and edges.
Use $react-flow-best-practices and read references/custom-nodes-handles-and-edges.md. Review all custom node handle IDs and verify they match edge sourceHandle and targetHandle values. Flag mismatches and unstable IDs.
Bewährte Verfahren
- Definieren Sie nodeTypes und edgeTypes außerhalb der Render-Funktion oder memoieren Sie sie. Inline-Erzeugung führt zu React Flow-Warnungen und kann benutzerdefinierte Nodes bei jedem Render neu mounten.
- Verwenden Sie typisierte Node- und Edge-Generics (Node<Data, Type>) für benutzerdefinierte Node- und Edge-Props, um Datenvertragsverletzungen bereits zur Compile-Zeit zu erkennen.
- Fügen Sie zu Buttons, Eingabefeldern und interaktiven Bedienelementen in benutzerdefinierten Nodes immer nodrag hinzu. Fügen Sie nopan zu Bedienelementen hinzu, die kein Canvas-Panning auslösen sollen.
Vermeiden
- Das gesamte nodes- oder edges-Array bei jeder Datenänderung neu erstellen, ohne Benutzerpositionen, Auswahlen oder transienten UI-Zustand zu erhalten. Dies behindert die Benutzerinteraktion.
- Aufruf von fitView in Effekten, die vom gesamten nodes-Array abhängen. Dadurch wird das Benutzer-Panning und -Zoomen nach jeder Datenänderung überschrieben.
- Handles mit display: none CSS verstecken. React Flow benötigt messbare Handle-Abmessungen. Verwenden Sie stattdessen visibility: hidden oder opacity: 0.
Häufig gestellte Fragen
Funktioniert diese Skill mit älteren react-flow-renderer-Versionen?
Kann diese Skill React Flow-Fehler automatisch beheben?
Überprüft die Skill die Laufzeitperformance?
Welche Projekte profitieren am meisten von dieser Skill?
Unterstützt diese Skill Edge-Labels mit interaktiven Bedienelementen?
Wie werden Handle-IDs auf Korrektheit überprüft?
Entwicklerdetails
Autor
JohnWayneeeeLizenz
MIT
Repository
https://github.com/JohnWayneeee/ai-agent-skills/tree/main/skills/react-flow-best-practicesRef
main
Dateistruktur