DEV Community

Write better Vue JS code

paschal on September 27, 2019

Introduction Architecture might not matter at the start of a project, but the ease at which components can be added or removed without b...
Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

I enjoyed using vuex for a shop I was building, but I am writing a portfolio now, I opted out of vuex, and yes I need a certain level of abstraction, but do you know what is better than local state management? No state, or atleast remote data. I have cut down on the need to use any of this with a headless CMS and graphql.

Collapse
 
jamesthomson profile image
James Thomson

Out of curiosity, what headless CMS are you using? Any articles you can recommend on this sort of stack? I've been very interested in giving GraphQL a go.

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€
Collapse
 
obbap profile image
paschal

Nice, that works also. The requirements of the application will justify how much a state management library is needed. Is there a repository for your shop ?

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

I can't share the shops sorry it's unde private control. But that is the vux stuff. If you are interested in my portfolio in Vue with graphcm I can share this WIP

Collapse
 
mratiebatie profile image
Sjors van Dongen

Nice article, thank you. I think it’s even better to use mapState instead of a getter when the variable is not changed in the getter. Getters are actually provided to adjust a variable before returning it.

Collapse
 
obbap profile image
paschal

True, When there are so many getters and things get verbose, mapState works fine, but mapState actually helps you create computed getter properties under the hood. So you're still using getters. I saw that here, vuex.vuejs.org/guide/state.html