Why don't stores automatically return refs? Curious of why pinia chose the 2-line useStore and storeToRefs pattern #1658
Unanswered
zachbryant
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I first started reading the docs on getters, I fell into the trap of thinking
state.myGetter
is good enough. Definitely a noob mistake. I learned aboutstoreToRefs
and it hasn't stopped bothering me since. I haven't yet come across a scenario where refs or computeds weren't explicitly necessary. What I don't understand is, why this pattern? Why not default to returning refs instead of reactives fromuseStore
calls? At least for how I'm using state, this pattern only ever feels in my way.When I think of this 2-line pattern, I wonder why I'm not using a singleton pattern with refs instead?
Beta Was this translation helpful? Give feedback.
All reactions