Switching from @tanstack/vue-query
to pinia-colada
#133
drahkrub
started this conversation in
Show and tell
Replies: 1 comment 5 replies
-
The behavior you are seeing comes from structural sharing. This behavior makes sense with React because it re renders many more things by default than Vue. Because Pinia Colada only supports Vue, it doesn't implement this behavior out of the box. It can be achieved with a plugin or by changing the watcher to only trigger if the data changes. In your case, it can be achieved like this: watch(
() => JSON.stringify(data.value),
(orgJson) => {
++counter.coladaWatch
if (orgJson) {
model.value = JSON.parse(orgJson)
}
},
{ immediate: true }
) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am using
@tanstack/vue-query
in a large SPA that contains a lot of form based editing. I have created a small demo project that shows (in a simplified form) how I use@tanstack/vue-query
when it comes to form editing. Since I want to switch topinia-colada
, the demo project contains a pagecolada.vue
, in which I try to use the same setup. It seems to work - until the content in the input field is changed (without clicking "save") and a different browser tab is visited. After returning to the tab with the running demo project the watcher unexpectedly fires and the content of the input field is reset - which isn't the case with@tanstack/vue-query
. Hard to explain ;-), just try it. Maybe my setup is wrong, of course I am open for improvements! Here is the link to my demo project:Beta Was this translation helpful? Give feedback.
All reactions