Skip to content

fix(docs): update example code for watch() #2041

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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