
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
A highly customizable React library for building node-based editors and interactive flow charts
React Flow is a library for building node-based editors and diagrams. It provides a set of components and utilities to create interactive and customizable flow charts, process diagrams, and more.
Creating a Basic Flow
This code demonstrates how to create a basic flow chart with nodes and edges using React Flow. The `elements` array defines the nodes and edges, and the `ReactFlow` component renders them.
import ReactFlow from 'reactflow';
import 'reactflow/dist/style.css';
const elements = [
{ id: '1', type: 'input', data: { label: 'Start' }, position: { x: 250, y: 0 } },
{ id: '2', data: { label: 'Step 1' }, position: { x: 100, y: 100 } },
{ id: '3', data: { label: 'Step 2' }, position: { x: 400, y: 100 } },
{ id: '4', type: 'output', data: { label: 'End' }, position: { x: 250, y: 200 } },
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e2-3', source: '2', target: '3' },
{ id: 'e3-4', source: '3', target: '4' }
];
function FlowChart() {
return <ReactFlow elements={elements} />;
}
export default FlowChart;
Custom Node Types
This code demonstrates how to create custom node types in React Flow. The `CustomNode` component defines the custom node, and the `nodeTypes` object maps the custom node type to the component.
import ReactFlow, { Handle } from 'reactflow';
import 'reactflow/dist/style.css';
const CustomNode = ({ data }) => {
return (
<div style={{ padding: 10, border: '1px solid #ddd', borderRadius: 5 }}>
<Handle type="target" position="top" />
<div>{data.label}</div>
<Handle type="source" position="bottom" />
</div>
);
};
const nodeTypes = { custom: CustomNode };
const elements = [
{ id: '1', type: 'custom', data: { label: 'Custom Node' }, position: { x: 250, y: 0 } }
];
function CustomNodeFlow() {
return <ReactFlow elements={elements} nodeTypes={nodeTypes} />;
}
export default CustomNodeFlow;
Interactive Features
This code demonstrates how to add interactive features to a flow chart in React Flow. It includes a MiniMap, Controls, and Background components, and allows users to connect nodes interactively.
import React, { useState } from 'react';
import ReactFlow, { addEdge, MiniMap, Controls, Background } from 'reactflow';
import 'reactflow/dist/style.css';
const initialElements = [
{ id: '1', type: 'input', data: { label: 'Start' }, position: { x: 250, y: 0 } },
{ id: '2', data: { label: 'Step 1' }, position: { x: 100, y: 100 } },
{ id: '3', data: { label: 'Step 2' }, position: { x: 400, y: 100 } },
{ id: '4', type: 'output', data: { label: 'End' }, position: { x: 250, y: 200 } }
];
function InteractiveFlow() {
const [elements, setElements] = useState(initialElements);
const onConnect = (params) => setElements((els) => addEdge(params, els));
return (
<ReactFlow elements={elements} onConnect={onConnect}>
<MiniMap />
<Controls />
<Background />
</ReactFlow>
);
}
export default InteractiveFlow;
Dagre-D3 is a library for rendering directed graphs using D3.js. It provides a way to create and layout directed graphs, but it requires more manual setup and customization compared to React Flow.
Cytoscape.js is a graph theory library for visualization and analysis. It offers a wide range of features for creating and manipulating graphs, but it has a steeper learning curve and is more complex than React Flow.
JointJS is a diagramming library that provides a flexible way to create and interact with diagrams. It offers more advanced features and customization options, but it can be more challenging to integrate with React compared to React Flow.
A highly customizable React component for building interactive graphs and node-based editors.
🚀 Getting Started | 📖 Documentation | 📺 Examples | ☎️ Discord | 💎 React Flow Pro
React Flow includes a small attribution that links to the React Flow website. We expect companies who are using React Flow commercially to subscribe to React Flow Pro if they want to remove the attribution. By subscribing you get access to other exclusive services like advanced examples, individual support or prioritized bug reports. In non-commercial applications you may hide the attribution without subscribing but are welcome to sponsor us on Github.
You can find more information in our React Flow Pro FAQs.
The easiest way to get the latest version of React Flow is to install it via npm:
npm install reactflow
This is only a very basic usage example of React Flow. To see everything that is possible with the library, please refer to the website for guides, examples and API reference.
import ReactFlow, { MiniMap, Controls } from 'reactflow';
function Flow({ nodes, edges, onNodesChange, onEdgesChange, onConnect }) {
return (
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
>
<MiniMap />
<Controls />
</ReactFlow>
);
}
Before you can start developing please make sure that you have yarn classic installed (npm i -g yarn
). Then install the dependencies using yarn: yarn
.
For local development, you can use yarn dev
. This will run preconstruct and build all the packages.
Testing is done with cypress. You can find the tests in the integration/flow
folder. In order to run the tests do:
npm run test
React Flow is developed and maintained by webkid, a web development agency with focus on data driven applications from Berlin. If you need help or want to talk to us about a collaboration, feel free to contact us:
You can also use our contact form or join the React Flow Discord Server.
React Flow was initially developed for datablocks, a graph-based editor for transforming, analyzing and visualizing data in your browser. Under the hood, React Flow depends on these great libraries:
React Flow is MIT licensed.
FAQs
A highly customizable React library for building node-based editors and interactive flow charts
The npm package reactflow receives a total of 524,880 weekly downloads. As such, reactflow popularity was classified as popular.
We found that reactflow demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.