-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Reactivity maybe be broken with nested computed and vue-router #10236
Comments
Thanks for looking and helping with this matter! I doubt that this is an Operating System specific problem, as I can reproduce the problem with the repository I provided on my Windows 10 computer. Also, the problem I'm facing with my real-life application has been reported/confirmed by Linux, Windows, and Mac users. Sorry for my previous lack of explanation, the problem here is that the
Hopefully, this helps clarify my previous report; sorry for the convoluted reproduction pattern, I tried trimming as much as I could! |
The double triggering of |
FYI Calling composables inside the render function is wrong usage and should be avoided. Composables should only be called once per component, inside |
Thanks for the additional insight, and sorry for this improper use of composables in my example! I have updated my example repository which produces the small problem I mentioned in my original post. It should not have calls to composable inside the render/template anymore. And I also got rid of irrelevant warnings. Hopefully, this makes it easier to understand the problem. 🙇 |
My guess is this is because in 3.4, chained /cc @johnsoncodehk |
@yyx990803 @johnsoncodehk I believe this is a timing issue about the
console.log('Unmounted Home - isAnyRoute:', isAnyRoute.value); // isAnyRoute is MaybeDIrty
if (!isAnyRoute.value) console.log('To the unknown~'); Here So, @CamilleDrapier I think it's not a good practice to use effects in |
Oops, found Johnson has a PR for this one after I commented 😂 |
Might be related, but we also encountered this issue on our in-house UI Component Library where a component was provided router link props. Here is the behavior minimally reproduced: On Vue 3.3.13 it works: playground (I had to use Vuetify Playground bc Vue SFC Playground wasnt behaving as expected no matter which version 3.3/3.4) |
This is no longer reproducible in 3.5 alpha. The fix in #11244 is not exactly equivalent to the 3.5 behavior and from my testing introduces potential memory leaks when the computed references out of component reactive sources. Considering we are planning to release 3.5 soonish, I will consider this fixed in 3.5 and avoid touching 3.4 logic in the meanwhile. |
Vue version
3.4.15
Link to minimal reproduction
https://github.com/CamilleDrapier/vue-test/
Steps to reproduce
npm install
npm run dev
Unknown
button/tabWhat is expected?
What is actually happening?
System Info
Any additional comments?
This repo comes with a couple of extra branches:
vue-3.3.13
that tries to confirm that the same code works as expected with Vue3.3.13
(please runnpm install
and rerun your server after switching branches)is-home
which uses a slightly less-nestedisHome
computed, which seems to work as expected.no-watch
, which comments out a watcher on the "offending isAnyRoute" computed. The application seems to work as expected.This problem could be related to other reactivity issues that were reported on the
3.4.X
branch, but it is a bit difficult for me to say if it is a duplicate of another issue. I could confirm that the same problem happens as well in3.4.13
, so maybe it is different than #10185 but might still be the same "narrow edge case" that is mentioned over there.Sorry in advance for this complex use case; if anything it might not affect many users, and it can probably be worked around if need be~ 🙇
The text was updated successfully, but these errors were encountered: