Skip to content

Commit ba72fda

Browse files
committed
refactor(core): throw err on next tick
Signed-off-by: braks <[email protected]>
1 parent bdf45fc commit ba72fda

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/core/src/composables/useEdge.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ export default function useEdge<Data = ElementData, CustomEvents extends Record<
2828
([nextEdge, nextId]) => {
2929
if (!nextId || nextId === '') {
3030
throw new VueFlowError('useEdge', `No node id provided and no injection could be found!`)
31-
} else if (!nextEdge) {
32-
throw new VueFlowError('useEdge', `Node with id ${edgeId.value} not found!`)
3331
}
32+
33+
nextTick(() => {
34+
if (!nextEdge) {
35+
throw new VueFlowError('useEdge', `Node with id ${edgeId.value} not found!`)
36+
}
37+
})
3438
},
35-
{ immediate: true },
39+
{ immediate: true, flush: 'post' },
3640
)
3741

3842
return {

packages/core/src/composables/useNode.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ export default function useNode<Data = ElementData, CustomEvents extends Record<
3232
([nextNode, nextId]) => {
3333
if (!nextId || nextId === '') {
3434
throw new VueFlowError('useNode', `No node id provided and no injection could be found!`)
35-
} else if (!nextNode) {
36-
throw new VueFlowError('useNode', `Node with id ${nodeId.value} not found!`)
3735
}
36+
37+
nextTick(() => {
38+
if (!nextNode) {
39+
throw new VueFlowError('useNode', `Node with id ${nodeId.value} not found!`)
40+
}
41+
})
3842
},
39-
{ immediate: true },
43+
{ immediate: true, flush: 'post' },
4044
)
4145

4246
return {

0 commit comments

Comments
 (0)