Skip to content

Commit 7f2917a

Browse files
committed
docs: update state page
1 parent 20d18ee commit 7f2917a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

docs/src/guide/vue-flow/state.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Consider this example, where we want to create a Sidebar that allows us to selec
4242
<div>
4343
<Sidebar />
4444
<div class="wrapper">
45-
<VueFlow v-model="elements" />
45+
<VueFlow :nodes="nodes" :edges="edges" />
4646
</div>
4747
</div>
4848
</template>
@@ -105,24 +105,28 @@ If you want to strictly control state changes you can disable this behavior by s
105105
to `false`.
106106

107107
```vue
108-
<div style="height: 300px">
109-
<VueFlow v-model="elements" :apply-default="false" />
110-
</div>
108+
<template>
109+
<VueFlow :nodes="nodes" :edges="edges" :apply-default="false" />
110+
</template>
111111
```
112112

113113
State changes are emitted by the `onNodesChange` or `onEdgesChange` events, which will provide an array of changes that
114114
have been triggered.
115115
To take control of state changes you can implement your own state update handlers or use the state helper functions that
116116
come with the library to mix it up.
117117

118+
::: info
119+
Read more about this in the [controlled flow](/guide/controlled-flow) guide.
120+
:::
121+
118122
## Access State in Options API
119123

120124
`useVueFlow` was designed to be used in the composition API, __but__ it is still possible to use it in the options API.
121125
Though it is necessary to pass a unique id for your Vue Flow state instance, otherwise a look-up will fail and Vue Flow
122126
will create a new state instance
123127
when mounted.
124128

125-
```vue{4,32}
129+
```vue
126130
<script>
127131
import { VueFlow, useVueFlow } from '@vue-flow/core'
128132
@@ -131,13 +135,14 @@ export default defineComponent({
131135
components: { VueFlow },
132136
data() {
133137
return {
134-
elements: [
138+
nodes: [
135139
{
136140
id: '1',
137-
label: 'Node 1',
138141
position: { x: 0, y: 0},
142+
data: { label: 'Node 1' }
139143
}
140-
]
144+
],
145+
edges: [],
141146
}
142147
},
143148
methods: {
@@ -153,7 +158,8 @@ export default defineComponent({
153158
}
154159
})
155160
</script>
161+
156162
<template>
157-
<VueFlow v-model="elements" id="options-api" @connect="handleConnect" />
163+
<VueFlow id="options-api" :nodes="nodes" :edges="edges" @connect="handleConnect" />
158164
</template>
159165
```

0 commit comments

Comments
 (0)