Skip to content

Commit

Permalink
fix(docs): update example code for watch() (#2041)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JeraldVin authored Nov 21, 2022
1 parent 8dc3cd9 commit 1d669d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/rules/no-setup-props-destructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This rule reports the destructuring of `props` passed to `setup` causing the val
export default {
/* ✓ GOOD */
setup(props) {
watch(() => {
watch(() => props.count, () => {
console.log(props.count)
})
Expand All @@ -45,8 +45,8 @@ Destructuring the `props` passed to `setup` will cause the value to lose reactiv
export default {
/* ✗ BAD */
setup({ count }) {
watch(() => {
console.log(count) // not going to detect changes
watch(() => count, () => { // not going to detect changes
console.log(count)
})
return () => {
Expand All @@ -70,7 +70,7 @@ export default {
/* ✗ BAD */
const { count } = props
watch(() => {
watch(() => props.count, () => {
/* ✓ GOOD */
const { count } = props
console.log(count)
Expand Down

0 comments on commit 1d669d3

Please sign in to comment.