Skip to content

Commit 1d669d3

Browse files
authored
fix(docs): update example code for watch() (#2041)
* fix(docs): update example code for watch() The 1st argument for watch() should be a ref/reactive/getter function/array of ref, reactive, getter function. But in the example code, the watch callback has been used as the 1st argument * chore: remove extra space
1 parent 8dc3cd9 commit 1d669d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/rules/no-setup-props-destructure.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This rule reports the destructuring of `props` passed to `setup` causing the val
2222
export default {
2323
/* ✓ GOOD */
2424
setup(props) {
25-
watch(() => {
25+
watch(() => props.count, () => {
2626
console.log(props.count)
2727
})
2828
@@ -45,8 +45,8 @@ Destructuring the `props` passed to `setup` will cause the value to lose reactiv
4545
export default {
4646
/* ✗ BAD */
4747
setup({ count }) {
48-
watch(() => {
49-
console.log(count) // not going to detect changes
48+
watch(() => count, () => { // not going to detect changes
49+
console.log(count)
5050
})
5151
5252
return () => {
@@ -70,7 +70,7 @@ export default {
7070
/* ✗ BAD */
7171
const { count } = props
7272
73-
watch(() => {
73+
watch(() => props.count, () => {
7474
/* ✓ GOOD */
7575
const { count } = props
7676
console.log(count)

0 commit comments

Comments
 (0)