Confused with returning Ref<T> as a type to a Pinia state #485
-
Beta Was this translation helpful? Give feedback.
Answered by
posva
May 10, 2021
Replies: 1 comment 8 replies
-
The state should return a plain object (it can be a reactive object as well). It cannot be a Ref. So maybe do: state() {
return {
user: useStorage<Authentication.UserProfile>(
"user",
{ accessToken: "", displayName: "", photoUrl: "", emailAddress: "" },
localStorage);
}
}, The problem is that from a typing perspective, it will think the type of |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The state should return a plain object (it can be a reactive object as well). It cannot be a Ref. So maybe do:
The problem is that from a typing perspective, it will think the type of
this.user
is a ref while in practice it isn't. I think we could unwrap refs automatically in pinia types