Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

watch callback has something side effect when calling createApp in the callback #6728

Open
deot opened this issue Sep 23, 2022 · 4 comments
Open
Labels
🐞 bug Something isn't working scope: reactivity

Comments

@deot
Copy link

deot commented Sep 23, 2022

Vue version

3.2.39

Link to minimal reproduction

SFC Playground

Steps to reproduce

  1. Open the demo@vue3.2.39
  2. After clicking it, log 1,1,2,2 will appear

CleanShot 2022-09-23 at 18 01 40

What is expected?

  1. open the demo@vue3.2.37
  2. After clicking it, log 1,2,1,2 will appear

CleanShot 2022-09-23 at 18 04 21

What is actually happening?

Log: 1, 1, 2, 2

System Info

No response

Any additional comments?

No response

@deot
Copy link
Author

deot commented Sep 23, 2022

A new problem after #6614 fixed

@edison1105 edison1105 added the 🐞 bug Something isn't working label Sep 28, 2022
@zhangzhonghe
Copy link
Member

Workaround:

watch(
  () => isActive.value,
  (v) => {
    if (v) {
     loadData()
    }
  },
  // use post
  { flush: 'post' }
)

@weidehai
Copy link

Workaround:

watch(
  () => isActive.value,
  (v) => {
    if (v) {
     loadData()
    }
  },
  // use post
  { flush: 'post' }
)

this workaround seems no work,vue will flush pre end post job when render a new component in vue 3.2.39

@jh-leong
Copy link
Contributor

jh-leong commented Nov 2, 2023

As a workaround, use a sync flush watcher:

watch(
  () => isActive.value,
  v => {
    // ...
  },
  { flush: 'sync' }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working scope: reactivity
Projects
None yet
Development

No branches or pull requests

6 participants