initializing store w/ this.$state not updating state on store instance #681
-
hi, not sure if i am just using bad practice code, so i opened a discussion instead of an issue. I was using pinia 2.0.0-beta.2 before updating to rc9. with the update my store initialization pattern broke; actually it breaks from 2.0.0-beta.4 on. i created two sandboxes with the same code but different pinia versions. beta2 works, rc9 doesn't. please checkout the basically i use what am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This seems like a regression to me, the code comment for
That evidently worked before but seems to break reactivity now if you do assign it. However as a quick fix, you can instead use // change the following
this.$state = data
// to this
this.$patch(data) |
Beta Was this translation helpful? Give feedback.
This seems like a regression to me, the code comment for
$state
does say:That evidently worked before but seems to break reactivity now if you do assign it.
My suggestion would be to create an issue for this.
However as a quick fix, you can instead use
$patch
which achieves the same result without breaking reactivity:Forked Sandbox