You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered that Pinia (unlike Vuex which I've migrated from) doesn't update whole objects (at least not nested ones) but only part of them. It doesn't matter if I'm trying to replace the objects directly nor with $patch...
Actually there are two issues. One - which I've mentioned above and second one, that Pinia also in such scenario doesn't remove properties from "old" object that are missing in a "new" one. It just leaves them. It's like Pinia cares only about changed properties and ignores everything else.
I'm working with some complex data, so it's desired for me to replace whole objects instead of picking and mutating certain single properties.
As I said - Vuex didn't have that issue, and since (according to the docs), Pinia is successor of Vuex, I didn't expect any changes in that regard.
I don't know if it's a bug, or if Pinia was just designed like that, but maybe there is some possibility to change that behavior?
Since I couldn't find any answers in the official docs nor on the web, I would be very thankful for anyone that could help me with these issues.
Edit: The only solution I came up with, is to first reset original object with undefined, or null for example, and then assign the new object to it. But as you can tell it's not the thing I would want to do at all ;)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I discovered that Pinia (unlike Vuex which I've migrated from) doesn't update whole objects (at least not nested ones) but only part of them. It doesn't matter if I'm trying to replace the objects directly nor with $patch...
Actually there are two issues. One - which I've mentioned above and second one, that Pinia also in such scenario doesn't remove properties from "old" object that are missing in a "new" one. It just leaves them. It's like Pinia cares only about changed properties and ignores everything else.
I'm working with some complex data, so it's desired for me to replace whole objects instead of picking and mutating certain single properties.
As I said - Vuex didn't have that issue, and since (according to the docs), Pinia is successor of Vuex, I didn't expect any changes in that regard.
I don't know if it's a bug, or if Pinia was just designed like that, but maybe there is some possibility to change that behavior?
Since I couldn't find any answers in the official docs nor on the web, I would be very thankful for anyone that could help me with these issues.
Edit: The only solution I came up with, is to first reset original object with
undefined
, ornull
for example, and then assign the new object to it. But as you can tell it's not the thing I would want to do at all ;)Beta Was this translation helpful? Give feedback.
All reactions