[Vuejs]-Vuex state is not reactive

0👍

I am not sure when you are using mapState, then why you are accessing through $store.

computed: {
  ...mapState(['isLoading'])
  // You can access `isLoading` as a property of `this` ex - this.isLoading

}

Now you can simply use the reactive property.

<template>
  <fulfilling-square-spinner
    v-show="isLoading"
    class="loading-spinner"
    :animation-duration="4000"
    :size="50"
    color="#007bff"
  />
</template>

Also you can use mapMutations for mutations too

methods: {
  ...mapMutations(['loading'])
  // it's get mapped as this.$store.commit('loading') and you can use as a property of this

  // this.loading()
}

Leave a comment