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

How to save and edit arrays in Store? #40

Closed
stiflerproger opened this issue Jun 11, 2019 · 1 comment
Closed

How to save and edit arrays in Store? #40

stiflerproger opened this issue Jun 11, 2019 · 1 comment

Comments

@stiflerproger
Copy link

I have this structure of Settings model
const state = { price_between: { enabled: false, value: [0,0] } }
Then change the value to [10, 10] via mutation;
state['price_between'].value = [10, 10]; and it works fine, and i get this array as expected.

But now i refresh page and get state:
state.price_between === [0, 0, 10, 10];

And every time i reload page, it just adding new values in array; I never use .push() or something. Always changing like value[0] = 10;

@stiflerproger
Copy link
Author

I think i found problem. Becouse on load module use deep-megre, arrays comparing by values, and add not existed before values.
I changed my structure to
const state = { price_between: { enabled: false, from: 0, to: 0 } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant