Skip to content

How to add new nodes in a custom pinia store #1148

Answered by bcakmakoglu
seppeclijsters asked this question in Q&A
Discussion options

You must be logged in to vote

Instead of using addNodes or addEdges simply push the new nodes / edges into your state.

const addNode = () => {
  const newNode = {
    type: 'custom',
    id: currentNode,
    label: divisionData.name,
    position: { x: 200, y:  100 },
  }
  
  divisions.push(newNode)

  divisions.push({
      source: previousNode,
      target: currentNode,
      type: 'step',
      sourceHandle: 'b',
      targetHandle: 'a',
    })
}

They will then be passed down to Vue Flow via the v-model you're using.
You don't need to use these helper functions to add nodes or edges.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@bcakmakoglu
Comment options

@seppeclijsters
Comment options

@seppeclijsters
Comment options

@bcakmakoglu
Comment options

@seppeclijsters
Comment options

Answer selected by seppeclijsters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants