Skip to content

Commit eca0447

Browse files
committed
chore(core): cleanup
1 parent 0e03b16 commit eca0447

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.changeset/cuddly-flies-change.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@
33
---
44

55
Add `updateNode` action
6+
7+
## 🧙 Example
8+
9+
```ts
10+
const { updateNode } = useVueFlow()
11+
12+
updateNode('1', { position: { x: 100, y: 100 } })
13+
14+
// or using a function to update the node
15+
updateNode('1', (node) => ({ ...node, position: { x: 100, y: 100 } }))
16+
17+
// passing options - `replace` will replace the node instead of merging it
18+
updateNode('1', { id: '1', label: 'Node 1', position: { x: 100, y: 100 } }, { replace: true })
19+
```

.changeset/nice-suits-pull.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@
33
---
44

55
Add `updateNodeData` action
6+
7+
## 🧙 Example
8+
9+
```ts
10+
const { updateNodeData } = useVueFlow()
11+
12+
updateNodeData('1', { foo: 'bar' })
13+
14+
// or using a function to update the data
15+
updateNodeData('1', (data) => ({ ...data, foo: 'bar' }))
16+
17+
// passing options - `replace` will replace the data instead of merging it
18+
updateNodeData('1', { foo: 'bar' }, { replace: true })
19+
```

packages/core/src/store/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export function useActions(
601601
}
602602

603603
// todo: maybe we should use a more immutable approach, this is a bit too much mutation and hard to maintain
604-
const updateNode: Actions['updateNode'] = (id, nodeUpdate, options = { replace: true }) => {
604+
const updateNode: Actions['updateNode'] = (id, nodeUpdate, options = { replace: false }) => {
605605
const node = findNode(id)
606606

607607
if (!node) {

0 commit comments

Comments
 (0)