diff --git a/website/src/markdown/docs/getting-started/BasicFunctions.js b/website/src/markdown/docs/getting-started/BasicFunctions.js
new file mode 100644
index 00000000..d70c3290
--- /dev/null
+++ b/website/src/markdown/docs/getting-started/BasicFunctions.js
@@ -0,0 +1,41 @@
+import React, { useState } from 'react';
+import ReactFlow, {
+ removeElements,
+ addEdge,
+ ReactFlowProvider,
+} from 'react-flow-renderer';
+
+const initialElements = [
+ {
+ id: '1',
+ type: 'input',
+ data: { label: 'Input Node' },
+ position: { x: 250, y: 25 },
+ },
+ {
+ id: '2',
+ data: { label: 'Another Node' },
+ position: { x: 100, y: 125 },
+ },
+];
+
+const BasicFlow = () => {
+ const [elements, setElements] = useState(initialElements);
+ const onElementsRemove = (elementsToRemove) =>
+ setElements((els) => removeElements(elementsToRemove, els));
+ const onConnect = (params) => setElements((els) => addEdge(params, els));
+
+ return (
+
+
+
+
+
+ );
+};
+
+export default BasicFlow;
diff --git a/website/src/markdown/docs/getting-started/index.md b/website/src/markdown/docs/getting-started/index.md
index 0eff4c11..44945faf 100644
--- a/website/src/markdown/docs/getting-started/index.md
+++ b/website/src/markdown/docs/getting-started/index.md
@@ -25,10 +25,9 @@ import React from 'react';
import ReactFlow from 'react-flow-renderer';
const elements = [
- // input node
{
id: '1',
- type: 'input',
+ type: 'input', // input node
data: { label: 'Input Node' },
position: { x: 250, y: 25 },
},
@@ -39,11 +38,9 @@ const elements = [
data: { label: Default Node
},
position: { x: 100, y: 125 },
},
- // output node
{
id: '3',
- type: 'output',
- // you can also pass a React component as a label
+ type: 'output', // output node
data: { label: 'Output Node' },
position: { x: 250, y: 250 },
},
@@ -52,11 +49,56 @@ const elements = [
{ id: 'e2-3', source: '2', target: '3' },
];
-const BasicFlow = () => ;
+export default () => ;
```
import Flow from './index';
-You can find more advanced examples in the [examples](reactflow.dev/examples/) section.
+## Basic Functionality
+
+We don’t do any state updates besides the positions. This means that you need to pass the functions to remove an element or connect nodes by yourself. You can implement your own ones or use the [helper functions](/docs/api/helper-functions/) that come with the library. Here you see an example of how to use the heler functions `removeElements` and `addEdge`.
+
+
+```jsx
+import React, { useState } from 'react';
+import ReactFlow, { removeElements, addEdge } from 'react-flow-renderer';
+
+const initialElements = [
+ {
+ id: '1',
+ type: 'input',
+ data: { label: 'Input Node' },
+ position: { x: 250, y: 25 },
+ },
+ {
+ id: '2',
+ data: { label: 'Another Node' },
+ position: { x: 100, y: 125 },
+ },
+];
+
+export default () => {
+ const [elements, setElements] = useState(initialElements);
+ const onElementsRemove = (elementsToRemove) =>
+ setElements((els) => removeElements(elementsToRemove, els));
+ const onConnect = (params) => setElements((els) => addEdge(params, els));
+
+ return (
+
+ );
+}
+```
+
+In this example you can connect nodes and remove selected nodes and edges with the delete key.
+
+import Basic from './BasicFunctions';
+
+
+
+You can find more advanced examples in the [examples](/examples/) section.
diff --git a/website/src/markdown/docs/index.md b/website/src/markdown/docs/index.md
index 61d562fe..436aad0b 100644
--- a/website/src/markdown/docs/index.md
+++ b/website/src/markdown/docs/index.md
@@ -12,5 +12,3 @@ React Flow is a library for building node-based applications. These can be simpl
* **Utils:** Snap-to-grid and graph [helper functions](#helper-functions)
* **Components:** [Background, Minimap and Controls](#components)
* **Reliable**: Written in [Typescript](https://www.typescriptlang.org/) and tested with [cypress](https://www.cypress.io/)
-
-In order to make this library as flexible as possible we don’t do any state updates besides the positions. This means that you need to pass the functions to remove an element or connect nodes by yourself. You can implement your own ones or use the helper functions that come with the library.
\ No newline at end of file
diff --git a/website/src/pages/index.js b/website/src/pages/index.js
index 22ec8269..cb6caac9 100644
--- a/website/src/pages/index.js
+++ b/website/src/pages/index.js
@@ -149,9 +149,7 @@ const Home = () => {
A flow consists of nodes and edges (or just nodes). Together we call
them elements. You can pass a set of elements as a prop to the
- ReactFlow component. Hereby all elements need unique ids. A node
- needs a position and a label and an edge needs a source (node id)
- and a target (node id). This is the most basic for a flow. A simple
+ ReactFlow component. This is the most basic for a flow. A simple
flow could look like this: