nuxt-community / composition-api

Composition API hooks for Nuxt 2.
https://composition-api.nuxtjs.org
MIT License
709 stars 100 forks source link

fix: computed property write operation warning on just page component #802

Open buglavecz opened 2 months ago

buglavecz commented 2 months ago

🐛 The bug I got this warning on just page component. image

🛠ī¸ To reproduce Steps to reproduce the behavior:

If define a computed property like this (array manipulate: map, find, filter etc):

const myComputed = computed(() => {
    return [{ item: 'a' }, { item: 'b' }].map(item => item);
});

return { myComputed }

If not return in the setup() function, then not show the warning message....

ℹī¸ Additional context In the options API, that working fine.

buglavecz commented 2 months ago

workaround:

const myComputed = computed({
    get() { return [{ item: 'a' }, { item: 'b' }].map(item => item); },
    set() {}
});
danielroe commented 2 months ago

this is unlikely to be related to this library and is probably a Vue core issue.

buglavecz commented 1 month ago

this is unlikely to be related to this library and is probably a Vue core issue.

@danielroe the strange thing is that the error only occurs in nuxt page components. so I thought it had something to do with this package...

danielroe commented 1 month ago

oh, that does sound more like it's an issue with nuxt

however vue 2 is EOL (and so is Nuxt 2) so unfortunately I am not planning to take time to look further into this. (apologies!) I hope the workaround you provided will serve you well. 🙏

buglavecz commented 1 month ago

@danielroe okay, no problem. thanks your answer.