Skip to content

How to update edge property ("animated") dynamically? #934

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

You must be logged in to vote

Props are readonly (this is imposed by Vue, read this section of the Vue docs) so trying to modify props will not work, that's why you get the error you quoted.

There's a couple of ways of going about this but the simplest way is to use the edge object from the store state directly and mutate it.

// from inside your edge component

const { edge } = useEdge()

// or
const { findEdge } = useVueFlow()
const edge = findEdge(id)

function toggleAnimate() {
	edge.animated = !edge.animated
}

Replies: 1 comment 2 replies

Comment options

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

@aadhyarupam
Comment options

Answer selected by aadhyarupam
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