Comments (23)
@chovyprognos In the composition API you would do that like so:
const a = computed({
get() {
// your getter
},
set(val) {
// your setter
}
})
from composition-api.
I'm getting this same warning but it's not even a computed variable.
const page: any = reactive({
content: null,
})
later :
const { fetch } = useFetch(async () => {
const pageData = await (fetch stuff...)
if (pageData) {
page.content = pageData
}
})
Setting page.content's value throws the warning about write operation.
Is there any way to avoid this weird warning?
from composition-api.
@davaipoka Hm, you're right. I had a computed that depended on two values (say countries
and user addresses
). The client-side render worked but the server-side didn't work (computed value was not pre-populated). When I added the dependencies the computed relies on - countries
and user addresses
refs to the setup function's return object, the server-side render started working.
Normally I wouldn't include those 2 refs in the return object - they're not used in the template. But if it makes it work it makes it work.
from composition-api.
just because this is the top search result for this error. i ran into this issue when i accidentally had a ref
attribute in my template that was named the same as a computed property. renaming/removing the ref
fixed things up for me.
from composition-api.
from composition-api.
I'll make sure to make an issue with a reproduction!
from composition-api.
In Vue3 the computed ref has an property effect normal ref don't have this property. Maybe we get / have something like this in @vue/composition-api
from composition-api.
Nope with @vue/composition-api computed and ref look the same...
from composition-api.
https://github.com/nuxt-community/composition-api/blob/main/src/fetch.ts#L263 Can we just add check if isReadonly(vm[key])
?
from composition-api.
Definitely worth a test.
from composition-api.
Update: after a quick test, we still can't detect readonly properties, once applied to the Vue instance.
from composition-api.
Is there a good workaround?
from composition-api.
@TheNoim The warning is annoying but it doesn't actually cause an issue.
from composition-api.
how do i create a setter?
from composition-api.
When using a vuex component that is computed and gets called in useFetch, there is an vuex Error:
do not mutate vuex store state outside mutation handlers.
Sad, that this can´t be ignored
from composition-api.
When using a vuex component that is computed and gets called in useFetch, there is an vuex Error:
do not mutate vuex store state outside mutation handlers.
Sad, that this can´t be ignored
He's right. I'm having the same issue. Is there any workaround?
from composition-api.
you should return in your return object await variable firstly and then return on nextline (in your return object) your computed property based on await variable. dont know why but its work
from composition-api.
Hi, I'm facing the same issue with:
"nuxt": "^2.15.8",
"@nuxtjs/composition-api": "^0.33.1",
If there is any update on how to fix that?
from composition-api.
Hi same here.
Any updates?
from composition-api.
Samsies
"nuxt": "^2.15.8",
"@nuxtjs/composition-api": "^0.31.0",
from composition-api.
@danielroe any news on this?
from composition-api.
Please do open a new issue with a reproduction and I'll be very happy to look into it. 🙏
from composition-api.
just because this is the top search result for this error. i ran into this issue when i accidentally had a
ref
attribute in my template that was named the same as a computed property. renaming/removing theref
fixed things up for me.
This was the case for me. Thanks.
from composition-api.
Related Issues (20)
- fix: Can't pass object to template after update the version from 0.32.0 to 0.33.x HOT 4
- fix: Error: Unknown file extension: [...]node_modules/pathe/dist/index.cjs HOT 2
- help: Cannot call useContext() inside watch() callback HOT 4
- help: Failed to compile with 1 errors * @nuxtjs/composition-api in ./.nuxt/composition-api/meta.mjs HOT 2
- feat: A method to opt-out of automatic use of useMeta HOT 1
- help: Before mount, await useFetch HOT 13
- help: A circular reference error occurs when useFetch and useRouter are used together. HOT 1
- help: The object containing exported methods in the setup function is an empty object.
- help: How to set 'noindex' for SEO for a specific component? HOT 1
- help: Computed property based on an object prop HOT 1
- fix: useContext().error() with useAsync() causes hydration error HOT 1
- help: Cannot use import statement outside a module HOT 4
- fix: Module should export a function: @nuxtjs/composition-api HOT 5
- help: I can't use useHead in nuxt 2 HOT 1
- help: i get a error that show "[error] (node:19103) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /home/apache/.jenkins/workspace/prod/node_modules/@nuxtjs/composition-api/package.json. Update this package.json to use a subpath pattern like "./*". "" when i run "npm i"
- fix: `redirectedFrom` not exists in `useRoute()`
- docs: How do I register middleware in script setup HOT 1
- help: I don't receive fresh data via useAsyncData when change params. HOT 1
- Extend package.json to be compatible with moduleResolution: bundler
- fix: watch and useRoute() not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composition-api.