DrowzyDeveloper
DrowzyDeveloper

Reputation: 1

Pinia getters throw runtime error after migrating to vue3 from vue2

I'm trying to migrate an old app that used to run on vuex3+vue2+typescript+vue-property-decorator, to a vue3+pinia+typescript solution. I started by removing vuex and installing pinia which worked fine.

However, after installing the @vue/compat: ^3.1.0 i got to the steps regarding the warnings, but I can't resolve this console error coming from my getter 'isDoneLoading'.

Uncaught TypeError: 'set' on proxy: trap returned falsish property 'isDoneLoading'        bootstrap:27
   at deepMergeData (vue.runtime.esm-bundler.js:5939:1)
   ...

I have tried removing all the places where the getter is used, which didn't work. The only thing that has removed the error has been to re-write the getter as a function. But of course I want to use the getter functionality from pinia. The following is a sample from my store and component code:

App.vue.ts

import pinia from "./stores";
import {useAppStore} from "./stores/appStore";
import { Component, Vue } from "vue-property-decorator";



export default class App extends Vue {
private appStore = useAppStore(pinia)
.
.
.
.
get isLoggedIn() {
  return this.authStore.isLoggedIn;
}

AppStore.ts

//AppStore.ts
export const useAppStore = defineStore("AuthStore", {
  state: () => {
    return {
      loaders: null,
.
.
  getters: {
    isDoneLoading(): boolean {
      return this.loaders !== null && !this.loaders?.done;
    }

stores/index.ts

import {createPinia} from "pinia"

const pinia = createPinia();

export default pinia;

I have looked into and removed all the places where i've used vue slots so it's not that. I have made sure that the state and getter names are different from eachother. I've set the getter to return true. None of it has worked so far. I've seen people using vue-property-decorator with vue3 so I think that it shouldn't be an issue. It feels like I've missed something from the pinia documentation, but then again, it was working before using it with the vue/compat-build.

Any help will be greatly appreciated

Thanks!

Upvotes: 0

Views: 535

Answers (0)

Related Questions