-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
[Vue warn] Computed is still dirty after getter evaluation #10341
Comments
I have a place where the alert points to a ref and this ref can be true or false. However, the component does not have computed. Ref is used to display markup after loading data in onMounted |
it would be nice if the warning from commit f7ba97f It occurs in common scenarios where deeper getter chains may retrigger effects. |
Hey guys, I'm attempting to add some information about this warning, what information do you think is helpful? |
Hi, it would be helpful to know the name of the computed triggering the warning, also if possible a way to know why the warning was triggered (for example it changed x times in x timespan). I do have in many places computed cascading, like one using up another and on and on, but in my opinion that should not trigger. Also I would like to know if the |
Agreed with @solaris7791 and @csicky. More information about the name of the computed and why, or at least being able to have some sort of configuration. I linked a pinia playground here showing a simple example of how It doesn't seem right to me that using |
|
I have a similar usecase, except my Pinia store is dynamically determined within the computed, so I can't really extract it outside the computed do you have any recommendations? My thought was to maybe do something like this: component.vue: <script setup>
import { pauseTracking, resetTracking } from "@vue/reactivity";
const item = computed(() => {
const itemType = someDynamicItemType // this comes from an API response or some other dependency
const itemId = someDynamicItemId
pauseTracking()
const store = piniaStoreFactory(itemType)
resetTracking()
return store.item(itemId)
}
)
</script> data-store.js: function genericStoreFuncGenerator(itemType) {
return () => {
//generic store with some tailoring based on the item type, setup an internal axios instance to a specific API endpoint etc...
const data = ref({})
const item = computed(()=> (id)=> data.value[id])
return {data, item}
}
}
function piniaStoreFactory(itemType) {
const useDynamicStore = defineStore(itemType, genericStoreFuncGenerator(itemType))
return useDynamicStore()
} Does this seem like a bad idea? I don't really understand the implications of pauseTrack + resetTracking |
@Doctor-wu I've patched |
You mean the getter? |
@Doctor-wu yes |
I don't think this warning makes any sense for simple use cases. As per this comment:
You can have a simple Pinia store with only state and no computed values, and you stilll get the Pinia warning. Shouldn't this be considered a bug with Pinia? |
Agreed, that's because |
Started a discussion on Pinia's side. Not sure if creating a bug is appropriate. |
#10386 Here's a PR for this |
I'm getting this warning without pinia in a component – occurs for me whenever I add a nuxtUI element. |
i started a nuxt3 project from scratch to investigate this warning.. just v-calendar module installed and.... warning flood |
@Doctor-wu I haven't been getting this warning anymore since upgrading to x.20. Did something change? |
that warning doesn't display by default in the x.20 version |
Now can be enabled with app.config.warnRecursiveComputed option. close vuejs#10341
Now can be enabled with app.config.warnRecursiveComputed option. close vuejs#10341
Vue version
3.4.19
Link to minimal reproduction
Steps to reproduce
After the last update I get this warning, but as far as I know I don't have side effects in the computed properties, eslint would warn me about this.
If there are such side effects, the warning is not helping me find them. To make this warning useful it would need to say the name of the computed property. As it is now, it is more just yellow noise in the console.
What is expected?
To either not show warnings, or if it does, to give me the exact name of the computed property and if possible why it thinks it is dirty.
What is actually happening?
I get warnings I can't act upon.
System Info
Any additional comments?
I am not sure if the computed properties it complains about are actual computed declared in the component or state data imported with
mapState
ormapGetters
The text was updated successfully, but these errors were encountered: