Skip to content

How Can I Emits Event From Nodes With Props 'node-types' #1432

Answered by bcakmakoglu
yczkhx-ths asked this question in Q&A
Discussion options

You must be logged in to vote

You can wrap custom nodes in the nodeTypes object as a function and pass additional props that way:

const nodeTypes = {
  selectorNode: (props: NodeProps) => h(ColorSelectorNode, { ...props, onFoo: () => console.log('foo') }),
}
<script lang="ts" setup>
import type { NodeProps } from '@vue-flow/core'

const props = defineProps<NodeProps>()

const emits = defineEmits(['foo'])
</script>

<template>
  <button @click="emits('foo')">foo</button>
</template>

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@yczkhx-ths
Comment options

@bcakmakoglu
Comment options

Answer selected by yczkhx-ths
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