{"id":16192,"library":"reactflow","title":"React Flow","description":"React Flow is a highly customizable React library for building interactive graphs, node-based editors, and complex flow charts. The package `reactflow` is currently at version 11.11.4, which represents the actively maintained v11 stable release line. The project maintains a consistent release cadence with frequent patch updates and less frequent minor/major releases. Key differentiators include its intuitive API for seamless zooming and panning, extensive customization options for both nodes and edges, performant rendering achieved by only re-rendering changed elements, and a rich set of hooks and utility functions for graph manipulation. It also provides essential plugin components like MiniMap, Controls, and Background out-of-the-box. The library is built with TypeScript and tested with Cypress, ensuring reliability and a robust developer experience. Users should note that the upcoming v12 release will transition to a new package name, `@xyflow/react`.","status":"active","version":"11.11.4","language":"javascript","source_language":"en","source_url":"https://github.com/xyflow/xyflow","tags":["javascript","react","node-based UI","graph","diagram","workflow","react-flow","typescript"],"install":[{"cmd":"npm install reactflow","lang":"bash","label":"npm"},{"cmd":"yarn add reactflow","lang":"bash","label":"yarn"},{"cmd":"pnpm add reactflow","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for React components and hooks.","package":"react","optional":false},{"reason":"Required for rendering React components to the DOM.","package":"react-dom","optional":false}],"imports":[{"note":"ReactFlow is the default export of the library, not a named export. Ensure you are importing the default component for the main canvas.","wrong":"import { ReactFlow } from 'reactflow';","symbol":"ReactFlow","correct":"import ReactFlow from 'reactflow';"},{"note":"Hooks like useNodesState, useEdgesState, and utilities like addEdge are named exports.","wrong":"import useNodesState from 'reactflow';","symbol":"useNodesState","correct":"import { useNodesState } from 'reactflow';"},{"note":"Helper components such as MiniMap, Controls, and Background are named exports.","wrong":"import MiniMap from 'reactflow';","symbol":"MiniMap","correct":"import { MiniMap, Controls, Background } from 'reactflow';"},{"note":"The core stylesheet is crucial for proper rendering and requires a direct import path to the `dist` folder.","wrong":"import 'reactflow/style.css';","symbol":"StyleSheet","correct":"import 'reactflow/dist/style.css';"}],"quickstart":{"code":"import { useCallback } from 'react';\nimport ReactFlow, {\n  MiniMap,\n  Controls,\n  Background,\n  useNodesState,\n  useEdgesState,\n  addEdge,\n} from 'reactflow';\n\nimport 'reactflow/dist/style.css';\n\nconst initialNodes = [\n  { id: '1', position: { x: 0, y: 0 }, data: { label: 'Node 1' } },\n  { id: '2', position: { x: 250, y: 150 }, data: { label: 'Node 2' } },\n  { id: '3', position: { x: 100, y: 250 }, data: { label: 'Node 3' } },\n];\n\nconst initialEdges = [\n  { id: 'e1-2', source: '1', target: '2', label: 'to the next' },\n  { id: 'e2-3', source: '2', target: '3', animated: true },\n];\n\nfunction Flow() {\n  const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);\n  const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);\n\n  const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), [setEdges]);\n\n  return (\n    <div style={{ width: '100vw', height: '100vh' }}>\n      <ReactFlow\n        nodes={nodes}\n        edges={edges}\n        onNodesChange={onNodesChange}\n        onEdgesChange={onEdgesChange}\n        onConnect={onConnect}\n        fitView\n      >\n        <MiniMap />\n        <Controls />\n        <Background variant=\"dots\" gap={12} size={1} />\n      </ReactFlow>\n    </div>\n  );\n}\n\nexport default Flow;\n","lang":"typescript","description":"This quickstart demonstrates a basic React Flow setup with initial nodes and edges, enabling drag, zoom, pan, and interactive connecting. It includes `MiniMap`, `Controls`, and `Background` components for enhanced user experience."},"warnings":[{"fix":"For new projects, consider installing `@xyflow/react` to use the latest v12 features. For existing v11 projects, refer to the `@xyflow/react` migration guide for detailed instructions on upgrading and adapting to the new API and package name.","message":"The `reactflow` package (v11) is being succeeded by `@xyflow/react` (v12). This transition involves a package name change and significant API updates. Users of `reactflow` should plan for a migration when moving to v12.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Always include `import 'reactflow/dist/style.css';` in your root component or a relevant entry file to ensure proper styling.","message":"Forgetting to import the `reactflow/dist/style.css` stylesheet will result in an unstyled and potentially non-functional React Flow canvas, as essential layout and component styles are missing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your project's `react` and `react-dom` versions are `17.0.0` or higher. Update your `package.json` dependencies and reinstall if necessary.","message":"React Flow requires `react` and `react-dom` as peer dependencies with versions `>=17`. Using older versions of React may lead to compatibility issues or errors.","severity":"gotcha","affected_versions":"<17.0.0"},{"fix":"Pass an object mapping your custom type names to their respective React components via the `nodeTypes` or `edgeTypes` prop: `<ReactFlow nodeTypes={nodeTypes} ... />`.","message":"When implementing custom nodes or edges, they must be explicitly registered with the `nodeTypes` and `edgeTypes` props on the `ReactFlow` component. Failing to do so will prevent your custom elements from rendering.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure all React Flow hooks are called within the top level of a functional React component. If using multiple React versions, ensure your bundler resolves to a single React instance.","cause":"React Flow hooks like `useNodesState` or `useEdgesState` are being called outside of a functional React component, or there are multiple instances of React loaded.","error":"Error: Invalid hook call. Hooks can only be called inside of the body of a function component."},{"fix":"Provide a defined `width` and `height` to the `div` wrapper around your `ReactFlow` component (e.g., `style={{ width: '100vw', height: '100vh' }}`). Additionally, verify that `import 'reactflow/dist/style.css';` is present in your application.","cause":"The `ReactFlow` component's container does not have explicit `width` and `height` CSS properties, or the `reactflow/dist/style.css` stylesheet is not imported.","error":"TypeError: Cannot read properties of undefined (reading 'x') (or similar rendering issues like nodes overlapping/not appearing)"},{"fix":"Ensure all desired components are explicitly imported using named imports: `import { MiniMap, Controls, Background } from 'reactflow';`","cause":"One of the optional UI components (MiniMap, Controls, Background) is used but not imported from `reactflow`.","error":"Minimap is not defined / Controls is not defined / Background is not defined"}],"ecosystem":"npm"}