If a new variable is added after the state is updated and not defined in the state at first, only $state can obtain it #1783
Answered
by
posva
vela666
asked this question in
Help and Questions
-
Can I only use $state or define variables in advance? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Nov 8, 2022
Replies: 1 comment 3 replies
-
Yes, this is normal: you have to declare your initial state. If for some reason, that's not possible to you, you have to manually declare both properties to access it diretly on the store. You can find an example at https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-state. Note you can also keep your way and only access the property through |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this is normal: you have to declare your initial state.
If for some reason, that's not possible to you, you have to manually declare both properties to access it diretly on the store. You can find an example at https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-state.
Note you can also keep your way and only access the property through
store.$state
if that is fine for you.