[vuex] do not mutate vuex store state outside mutation handlers. #10747
-
|
I running the app in SRR mode/ Quasar2 and getting this error when trying to commit data: MainLayout.vue test.storejs Knowing that this error doesn't appear on SPA, it only appears if the mode is SSR, and it also doesn't appear if I set |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I think the issue is in your commit code. You are assigning an array to a variable that has been made observable. So, you cannot replace it. Change this line of code: state.data1 = payload;to: state.data1.splice(0, state.data1.length, ...payload);For this to work, your initial state needs to be like this: const state = {
data1:[], // <-- replace the null with []
}; |
Beta Was this translation helpful? Give feedback.

I think the issue is in your commit code. You are assigning an array to a variable that has been made observable. So, you cannot replace it.
Change this line of code:
to:
For this to work, your initial state needs to be like this: