No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    [Vue warn]: Error in callback for watcher "function () { return this._data.$$state }": "Error: [vuex] Do not mutate vuex store state outside mutation handlers."

    Help
    7
    10
    21347
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Epo last edited by

      I use a List for rendering my todos, which are managed with vuex. Im not sure why i got this error.

       <q-list inset-separator>
            <q-item
              v-for="(todo, key, index) in todos"
              :key="todo.id"
              name="myTodos">
              <q-item-side>
                <q-checkbox color="secondary" v-model="todo.done" @change="changeTodo(todo.id)" />
              </q-item-side>
              <q-item-main :label="todo.todo" />
              <q-item-side right icon="more_vert">
                <q-popover ref="popover">
                  <q-list link>
                    <q-item @click="removeTodo(todo.id)">
                      <q-item-main label="Delete" />
                    </q-item>
                  </q-list>
                </q-popover>
              </q-item-side>
            </q-item>
          </q-list>
      

      Here is my method which calls the vuex action:

       changeTodo (todo) {
         this.selectedTodo = this.todos[todo]
         this.updateTodo(this.selectedTodo)
       },
      

      Here i get the state:

       computed: {
          ...mapState({
            'todos': state => state.todos.todos
         })
        },
      

      Vuex and app works fine and also the state is updated but i got this error too.

      1 Reply Last reply Reply Quote 0
      • E
        Epo last edited by

        The problem is in v-model=“todo.done”. What did i wrong?

        1 Reply Last reply Reply Quote 0
        • E
          Epo last edited by

          I replaced

           v-model="todo.done"
          

          with

            :value="todo.done".
          

          Now it works fine. But when do i use/need v-model?

          1 Reply Last reply Reply Quote 0
          • M
            Muniraj last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • M
              Mirzo last edited by Mirzo

              I am having the same problem but :value didn’t help. Can anyone help me please???
              I have two errors when i click checkboxes:

              1. [Vue warn]: Error in callback for watcher “function () { return this._data.$$state }”: “Error: [vuex] do not mutate vuex store state outside mutation handlers.”
              2. warn @ vue.runtime.esm.js?2b0e:619 Error: [vuex] do not mutate vuex store state outside mutation handlers.
              1 Reply Last reply Reply Quote 0
              • M
                Mirzo last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • O
                  Oliver_Max last edited by

                  I have same problem. Did you solve it?

                  1 Reply Last reply Reply Quote 0
                  • S
                    s_sharunov last edited by

                    Hi guys.
                    I had the same problem - when one clicks directly on the checkbox field the error appears. My solution is: add a class to the tag of q-checkbox, i.e.

                    <q-checkbox v-model=“todo.done” class=“no-pointer-events” />

                    Thank you to youtube channel of Danny Connell. He provides his code-base, where the solution was found

                    1 Reply Last reply Reply Quote 1
                    • M
                      Muhammad Amin last edited by

                      Hello to everyone,
                      Look at here:
                      https://stackoverflow.com/questions/46044276/vuex-do-not-mutate-vuex-store-state-outside-mutation-handlers
                      https://vuex.vuejs.org/guide/forms.html
                      https://markus.oberlehner.net/blog/form-fields-two-way-data-binding-and-vuex/
                      https://github.com/maoberlehner/vuex-map-fields
                      http://shzhangji.com/blog/2018/04/17/form-handling-in-vuex-strict-mode/

                      1 Reply Last reply Reply Quote 1
                      • L
                        Lou Rectoret last edited by

                        What is really happening is that you’re referencing your store’s todos to components’s todos to.
                        You should clone the array instead:

                        I found myself in the same situation but with members, and this solved the issue:

                         const clonedMembers: [...this.formData.members]
                        // then you call the mutation with the clone
                        

                        Yes… is a pain in the ass.

                        I think this is solved in Vue3.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post