Skip to Content

2024-05-06

Devtools and a fresh overview example

Moritz Klack
Co-Founder

Sometimes it’s hard to understand what’s going on in your React Flow app. That’s why we’ve added a devtools section to the docs. It’s a copy pastable example that explains how you can get some insights into your React Flow app. We also published a revised version of the feature overview example.

Check it out below!

import React, { useCallback } from 'react'; import { ReactFlow, addEdge, MiniMap, Controls, Background, useNodesState, useEdgesState, } from '@xyflow/react'; import '@xyflow/react/dist/style.css'; import { nodes as initialNodes, edges as initialEdges, } from './initial-elements'; import AnnotationNode from './AnnotationNode'; import ToolbarNode from './ToolbarNode'; import ResizerNode from './ResizerNode'; import CircleNode from './CircleNode'; import TextInputNode from './TextInputNode'; import ButtonEdge from './ButtonEdge'; const nodeTypes = { annotation: AnnotationNode, tools: ToolbarNode, resizer: ResizerNode, circle: CircleNode, textinput: TextInputNode, }; const edgeTypes = { button: ButtonEdge, }; const nodeClassName = (node) => node.type; const OverviewFlow = () => { const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); const onConnect = useCallback( (params) => setEdges((eds) => addEdge(params, eds)), [], ); return ( <ReactFlow nodes={nodes} edges={edges} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={onConnect} fitView attributionPosition="top-right" nodeTypes={nodeTypes} edgeTypes={edgeTypes} > <MiniMap zoomable pannable nodeClassName={nodeClassName} /> <Controls /> <Background /> </ReactFlow> ); }; export default OverviewFlow;

Get Pro examples, prioritized bug reports, 1:1 support from the maintainers, and more with React Flow Pro

Last updated on