Questions tagged [vuex]

Vuex is a state management pattern + library for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.

Vuex is a data management library by the creator of Vue.js. It is designed to help build larger applications in a more maintainable way by following principles similar to those made popular by Facebook’s Flux library (and subsequent iterations by community like redux).

Principles

  • Terse
  • Testable
  • Reactive
  • Single State Tree
  • Hot Reloading
  • Time Travel (with vue-devtools support)

GitHub: https://github.com/vuejs/vuex Documentation: https://vuex.vuejs.org/en/

7756 questions
30
votes
2 answers

vue & vuex getter vs passing state via props

I have seen many people advising to pass state to components via props rather than accessing the vue state directly inside the component in order to make it more reusable. However, if I do this consistently this would mean that only the routes root…
Chris
  • 13,100
  • 23
  • 79
  • 162
29
votes
9 answers

Error: Cannot find module 'vue-loader-v16/package.json'

i am new to vue.js, just coming from react.js. the problem i am facing with the vue loader didn't happened at first. but from the second time the app crashes from starting the server. npm run serve > todo@0.1.0 serve…
Riyad Zaigirdar
  • 691
  • 3
  • 8
  • 22
29
votes
5 answers

Updating state of vuex array when one item has some changes

I have an array called cases in my vuex store. I want to update the array with the new content when I update a few fields within an existing item in the array. I thought I could do something like this in my mutation but doesn't work and get the…
Paul
  • 581
  • 3
  • 10
  • 19
29
votes
8 answers

Best Practice in Error Handling in Vuejs With Vuex and Axios

I am using Vuex + axios, I want to know the best practice in handling errors for vuex + axios. What I am doing now is that when I request using axios and it returns an error, it will be committed in mutation and update my state. What I want to do…
LordGrim
  • 731
  • 2
  • 11
  • 22
29
votes
4 answers

What exactly is namespacing of modules in vuex

I have recently started with vuex. The official docs explains well what modules are but i am not sure if i understood the namespaces in modules right. Can anybody put some light on namespaces in a better way? When/why to use it? Much appreciated.
Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
29
votes
5 answers

vuex namespaced mapState with multiple modules

I must be missing something. How can I use vuex mapState with multiple modules? As far as understand, besides passing an object as argument, namespaced mapState can take two arguments: namespace and an array of object names denoting the members of…
LongHike
  • 4,016
  • 4
  • 37
  • 76
28
votes
1 answer

Vuex - When to use getters and when to use state

I have a hard time figuring out when to use a getter or a state for best performance. I will list some scenarios that you are welcome to comment on: Scenario 1 - Getters VS state in actions and getters In an action or getter, if you use a list of…
LuckyJack
  • 285
  • 1
  • 3
  • 8
27
votes
1 answer

How to dispatch action from a javascript file (instead of a vue component)?

I have one module(javascript file) outside of vue context. i need to dispatch action from this javascript file. is it possible ? if yes, then how ? jsfile.js(Javascript file) const detail = {}; detail.validateLocation = (location) => { // need to…
Mukund Kumar
  • 21,413
  • 18
  • 59
  • 79
27
votes
3 answers

Why is computed value not updated after vuex store update?

I got a printerList computed property that should be re-evaluated after getPrinters() resolve, but it look like it's not. sources are online: optbox.component.vue, vuex, optboxes.service.js Component