Giter Club home page Giter Club logo

Comments (23)

danielroe avatar danielroe commented on May 29, 2024 14

@chovyprognos In the composition API you would do that like so:

const a = computed({
  get() {
    // your getter
  },
  set(val) {
    // your setter
  }
})

from composition-api.

QuentinLeCaignec avatar QuentinLeCaignec commented on May 29, 2024 4

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.

sethidden avatar sethidden commented on May 29, 2024 3

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

broox avatar broox commented on May 29, 2024 2

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.

mathe42 avatar mathe42 commented on May 29, 2024 1

see vuejs/composition-api#445

from composition-api.

SebbeJohansson avatar SebbeJohansson commented on May 29, 2024 1

I'll make sure to make an issue with a reproduction!

from composition-api.

mathe42 avatar mathe42 commented on May 29, 2024

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.

mathe42 avatar mathe42 commented on May 29, 2024

Nope with @vue/composition-api computed and ref look the same...

from composition-api.

mathe42 avatar mathe42 commented on May 29, 2024

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.

danielroe avatar danielroe commented on May 29, 2024

Definitely worth a test.

from composition-api.

danielroe avatar danielroe commented on May 29, 2024

Update: after a quick test, we still can't detect readonly properties, once applied to the Vue instance.

from composition-api.

TheNoim avatar TheNoim commented on May 29, 2024

Is there a good workaround?

from composition-api.

danielroe avatar danielroe commented on May 29, 2024

@TheNoim The warning is annoying but it doesn't actually cause an issue.

from composition-api.

chovyprognos avatar chovyprognos commented on May 29, 2024

how do i create a setter?

from composition-api.

develth avatar develth commented on May 29, 2024

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.

naquiroz avatar naquiroz commented on May 29, 2024

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.

davaipoka avatar davaipoka commented on May 29, 2024

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.

LCseniordev avatar LCseniordev commented on May 29, 2024

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.

Daewon25 avatar Daewon25 commented on May 29, 2024

Hi same here.
Any updates?

from composition-api.

bensinca avatar bensinca commented on May 29, 2024

Samsies

 "nuxt": "^2.15.8",
 "@nuxtjs/composition-api": "^0.31.0",

from composition-api.

SebbeJohansson avatar SebbeJohansson commented on May 29, 2024

@danielroe any news on this?

from composition-api.

danielroe avatar danielroe commented on May 29, 2024

Please do open a new issue with a reproduction and I'll be very happy to look into it. 🙏

from composition-api.

andreiculda avatar andreiculda commented on May 29, 2024

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.

This was the case for me. Thanks.

from composition-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.