I want to try to detect loops when I create an edge, but when I use MAP to store data, it doesn't update in time, I don't know what's wrong, can you help me? #880
Unanswered
ThisSeanZhang
asked this question in
Q&A
Replies: 1 comment 2 replies
-
What do you mean exactly it doesn't update in time? The code isn't really to clear on what is supposed to happen tbh. But I guess you want to avoid having loops? Something like this should work onConnect((params) => {
const sourceNodeEdges = getConnectedEdges([{ id: params.source }], edges.value)
const isLoop = sourceNodeEdges.some((edge) => edge.target === params.source)
if (!isLoop) {
addEdges([params])
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to try to detect loops when I create an edge,
but when I use MAP to store data, it doesn't update in time, 😢
I don't know what's wrong, can you help me? 🙏
Beta Was this translation helpful? Give feedback.
All reactions