composition-api icon indicating copy to clipboard operation
composition-api copied to clipboard

fix: computed property write operation warning on just page component

Open buglavecz opened this issue 1 year ago â€ĸ 5 comments

🐛 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 avatar Sep 30 '24 09:09 buglavecz

workaround:

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

buglavecz avatar Sep 30 '24 09:09 buglavecz

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

danielroe avatar Sep 30 '24 11:09 danielroe

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...

buglavecz avatar Oct 01 '24 04:10 buglavecz

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. 🙏

danielroe avatar Oct 01 '24 14:10 danielroe

@danielroe okay, no problem. thanks your answer.

buglavecz avatar Oct 01 '24 15:10 buglavecz