Skip to content

🐛 [BUG]: Node added in onMounted() is not rendered #1352

Open
@DavidPfl

Description

@DavidPfl

Is there an existing issue for this?

  • I have searched the existing issues and this is a new bug.

Current Behavior

I use the example shown in Adding nodes to the graph.
The node that is pushed in the onMounted() function is not rendered.
When I use Vue dev tools, I see that the event nodesInitialized event does not contain the node that is pushed to the elements array in onMounted(), but only the node that is part of the initial elements definition.

Here is the code I'm using:

<script setup>
import { ref, onMounted } from 'vue'
import { VueFlow } from '@vue-flow/core'

const elements = ref([
  {
    id: '1',
    position: { x: 50, y: 50 },
    label: 'Node 1',
  }
]);

onMounted(() => {
  elements.value.push({
    id: '2',
    label: 'Node 2',
    position: { x: 150, y: 50 },
  })
})
</script>

<template>
  <VueFlow v-model="elements"/>
</template>

Expected Behavior

I expect the node that is pushed to the elements array to be rendered when I refresh the page.

Steps To Reproduce

  1. Use the code from the first example in Adding nodes to the graph
  2. npm run dev in your App folder

Relevant log output

No response

Anything else?

As per my package-lock.json, I am using "@vue-flow/core": "^1.33.4".

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions