Skip to content

Commit 3a40518

Browse files
authored
Add inject example to reactive section of docs (#677)
This example might come in handy for users that are yet to read on `Computed and Watch` in the documentation so they know that the properties they're making reactive using `computed` is available under `property.value` and not `property`.
1 parent 881e133 commit 3a40518

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/guide/component-provide-inject.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ app.component('todo-list', {
107107
}
108108
}
109109
})
110+
111+
app.component('todo-list-statistics', {
112+
inject: ['todoLength'],
113+
created() {
114+
console.log(`Injected property: ${this.todoLength.value}`) // > Injected property: 5
115+
}
116+
})
110117
```
111118

112-
In this, any change to `todos.length` will be reflected correctly in the components, where `todoLength` is injected. Read more about `reactive` provide/inject in the [Composition API section](composition-api-provide-inject.html#reactivity)
119+
In this, any change to `todos.length` will be reflected correctly in the components, where `todoLength` is injected. Read more about `computed` in the [Computed and Watch section](reactivity-computed-watchers.html#computed-values) and `reactive` provide/inject in the [Composition API section](composition-api-provide-inject.html#reactivity).

0 commit comments

Comments
 (0)