reaviz / reaflow

🎯 React library for building workflow editors, flow charts and diagrams. Maintained by @goodcodeus.
https://reaflow.dev
Apache License 2.0
2.07k stars 120 forks source link

`setEdges` is undefined on Storybook demo #42

Closed Vadorequest closed 3 years ago

Vadorequest commented 3 years ago

https://reaflow.dev/?path=/story/docs-getting-started-linking-nodes--page

image

Uses a setEdges function which isn't defined anywhere.

amcdnl commented 3 years ago

Ya - the code is meant to be more of psuedo code but I will fix it to be more clear.

Vadorequest commented 3 years ago

I think adding some comment above the function like "coming from useState or similar would be enough.

Or add a more complete example such as:

  const [nodes, setNodes] = useState<NodeData[]>([
    {
      id: '2',
      text: 'Mother',
      data: {
        gender: 'female',
      },
    },
    {
      id: '3',
      text: 'Daughter',
      data: {
        gender: 'female',
      },
    },
    {
      id: '4',
      text: 'Son',
      data: {
        gender: 'male',
      },
    },
  ]);
  const [edges, setEdges] = useState<EdgeData[]>([
    {
      id: '2-3',
      from: '2',
      to: '3',
    },
    {
      id: '2-4',
      from: '2',
      to: '4',
    },
  ]);
amcdnl commented 3 years ago

Care to make a PR to add this?

Vadorequest commented 3 years ago

Documentation updated in https://github.com/reaviz/reaflow/pull/72