by peteradio · 6y ago · 0 comments
@@ -2,6 +2,8 @@
import Diagram, { createSchema, useSchema } from 'beautiful-react-diagrams';
import { Button } from 'beautiful-react-ui';
+let lastid=1
+
const initialSchema = createSchema({
nodes: [
{
@@ -39,8 +41,8 @@ const UncontrolledDiagram = () => {
const addNewNode = () => {
const nextNode = {
- id: `node-${schema.nodes.length+1}`,
- content: `Node ${schema.nodes.length+1}`,
+ id: `node-${lastid+=1}`,
+ content: `Node ${lastid}`,
coordinates: [
schema.nodes[schema.nodes.length - 1].coordinates[0] + 100,
schema.nodes[schema.nodes.length - 1].coordinates[1],Changing it to be a random string that gets created inside addNewNode instead removes all those issues.