Proper way to register custom type in store state? #1178
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As a general advice: Vue's reactivity work best with primitive data, that's true for both runtime and the types. And generally, it's also recommended to keep complex objects with side effects or complex internal state non-reactive, as you might get unintented side-effects when you make these object's properties reactive, depending on the internal interactions. This specific issue is, as far as I can tell from the information provided, because of Generics not working too well with Vue's (type) unwrapping of refs when the generic could be a ref. I can't pin it down for your types here as I don't know them all (i.e.: what's const x = { foo: ref('bar') }
// => shape: { foo: Ref<string> }
const reactiveX = reactive(x)
// => shape: { foo: string } There are generally two ways to solve this depending on the requirements:
this is not a Pinia problem, |
Beta Was this translation helpful? Give feedback.
As a general advice:
Vue's reactivity work best with primitive data, that's true for both runtime and the types. And generally, it's also recommended to keep complex objects with side effects or complex internal state non-reactive, as you might get unintented side-effects when you make these object's properties reactive, depending on the internal interactions.
This specific issue is, as far as I can tell from the information provided, because of Generics not working too well with Vue's (type) unwrapping of refs when the generic could be a ref.
I can't pin it down for your types here as I don't know them all (i.e.: what's
Int
?), but generally, if a generic's specific value could potentiall…