Vuex mutations sets state stack overflow

when using vuex, use

in vue pages
this.$store.commit("mapSet",map);

to call mutations to change state, but in mutations

 mapSet:(state,map)=>{
            console.log(map);
            state.myMap=map;
        }
    

but it is normal to output map objects when the page is called, but stack overflows are reported when assigning values. What is the error? How to solve the problem?

clipboard.png

Mar.21,2021

endless loop. Setting myMap triggers commit again


although I don't know why, I find that when setting state, do not set it to null, for example:
a:null / / it will report an error, stack overflow
a: {} / / this setting will be better
and, in mutations, assign the parameter to the attribute of state. For example:
a.a = parameter
so that the assignment will be correct and will not report an error.
this is how to solve this problem for the time being. The specific principle is not very clear. Please give us your advice

.
Menu