On the official Vuex documentation and guides available on the internet, it is mentioned that in order to access your store state or getter, you have to create a computed property that returns the data you need (ex. this.$store.state.info), or you can use a MapState helper.
I access Vuex data on template referencing it directly on the template like this:
<p> {{ $store.state.info }} </p>
The same for getters. It works fine, but I wonder if I am making a mistake because all articles I have read about Vuex doesn't do like this. The guides always create a computed property directly using MapState or MapGetter.
Do you think it is fine the way I am doing or it is wrong and I might encounter a bug later in my project, it is just not a best practice or it is fine to use Vuex the way I do?
mapState
helper:When a component needs to make use of multiple store state properties or getters, declaring all these computed properties can get repetitive and verbose. To deal with this we can make use of the mapState helper which generates computed getter functions for us, saving us some keystrokes
. If your template contained only a few references to$store.state
and it were easily readable, it's probably fine IMO. You won't encounter a bug just because you're not using the helper – tony19