Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can’t I assign a socketio object to state in strict mode? #1518

Closed
zzzgit opened this Issue Mar 8, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@zzzgit
Copy link

zzzgit commented Mar 8, 2019

Version

3.1.0

Reproduction link

Steps to reproduce

image
image
image

What is expected?

What is actually happening?

in strict mode, I can't assign socket object to state.
is there a solution?

@Jinjiang

This comment has been minimized.

Copy link
Member

Jinjiang commented Mar 10, 2019

Couldn't see your full project. But I guess the socket you pass in is not a plain JavaScript object that leads to error. Because the state must be a plain JavaScript object.
Next time if you have more question, it's better to supply more information.
Thanks.

@Jinjiang Jinjiang closed this Mar 10, 2019

@zzzgit

This comment has been minimized.

Copy link
Author

zzzgit commented Mar 11, 2019

Because the state must be a plain JavaScript object.

Is it in the documentation?

@Jinjiang

This comment has been minimized.

Copy link
Member

Jinjiang commented Mar 14, 2019

https://vuex.vuejs.org/guide/#getting-started
https://vuejs.org/v2/guide/reactivity.html#How-Changes-Are-Tracked
These two pages might be help you understand that. Anyway, you make a point, it might be better to be emphasized on the docs.

@Jinjiang

This comment has been minimized.

Copy link
Member

Jinjiang commented Mar 14, 2019

I made a double-check and found that it triggered this line of code:

assert(store._committing, `do not mutate vuex store state outside mutation handlers.`)

That because you enable strict mode and mutate state directly through a function "function () { return this._data.$$state }". I suggest you go search where this function comes from in your project. Or disable strict mode.

About strict mode: https://vuex.vuejs.org/guide/strict.html

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.