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]: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead. #2027
Comments
Your use case can and should be rewritten using a computed property instead: const id = computed(() => {
return Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
}) If you must use a watcher, you should also use watchEffect(() => {
id.value = Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
}) |
@yyx990803 Your response makes sense, but permit me to note that it disagrees with the documentation for view-router-next, which explicitly calls for watching the route object. I do not know how to reconcile between two core Vue projects. |
Can you point me the part of the documentation so I can take a look? |
Thanks! |
@yyx990803 How about setting |
我在vue3 中试用了 vue2 的watch: { $route(newVal, oldVal) {...}} 也会看到这个报警, 这个怎么解决? |
vue3 中,这个是devtools 6.0.0 beta 2打印的,我把devtools关闭,这个waring就消失了 |
Close vue-devtools and the warning will disappear. This should be the problem with DevTools |
请问怎么关闭 vue-devtools (vue3) |
same situation with u, it's OK when I closed devtool. |
You can specify |
set devtools in “when u click the extension” mode |
https://next.router.vuejs.org/guide/advanced/composition-api.html#accessing-the-router-and-current-route-inside-setup |
For me it's because of my Axios requests ...Whenever I use an Axios (or even fetch doesn't matter) I get this warning...It doesn't vanish even with disabling devtools (So It has nothing to do with the devtools). |
I'm encoutering a similar issue when dispatching an action to store AG-Grid's Model in my Vuex store. Specifically this bit of code UPDATE: So I just removed the "CreateLogger" plugin from my store and the warnings went away. It looks like the logger is causing these in certain circumstances. |
Are there other known causes of this "Avoid app logic" warning? I am migrating from Vue 2 to 3, and some routes show this warning in the console hundreds, if not thousands of times on one page. |
Saving a component and triggering HMR also causes this warning to show up multiple times. |
It looks like these warnings are coming from the new vue dev tools chrome extension. |
This happens to me when destructuring a ref without |
On another note, this error popped up for me today and it was inside an Ionic/Vue3 project. And it was related to using an Ionic component - in my case the IonChip component - without importing it. So its reference in my template without the import was the culprit. |
Currently migrating nuxt 2 project to nuxt 3 and I started getting this error as well. What I've noticed is that it doesn't happen because of something specific, but rather because of some other errors happening. For example in my case since we wanted to still use vuex in nuxt 3, I was using For anyone experiencing this error, I suggest you start commenting code little by little so you find the culprit in your codebase, but unfortunately there's no specific fix as the warning itself doesn't describe what's wrong exactly |
Version
3.0.0-rc.9
Reproduction link
https://github.com/rothskeller/vuewarnreport
Steps to reproduce
What is expected?
No warning.
What is actually happening?
[Vue warn]: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.
First, note that this is the same symptom as #1991 but not the same cause.
This is happening because of the call to
watch(route, ...)
which is made inclient/src/pages/ID.vue
. The route object has within it a reference to the component, so watching the route includes watching the component, which triggers the warning. But watching the route for changes is a typical, and indeed essential, idiom in vue-router which should not result in a console warning. I don't know whether this should be considered a vue-next bug or a vue-router-next bug, but I'm guessing the former.The text was updated successfully, but these errors were encountered: