Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
In Vuex, why are the module's state accessed as 'store.state.module' instead of 'store.module.state'?

In the following code, why is the state of moduleA accessed with store.state.a instead of store.a.state?

Since the store holds moduleA, and moduleA holds its state, it makes more sense to me if the state of moduleA was accessed with store.a.state.

const moduleA = {
  state: () => ({ ... }),
  ...
}

const moduleB = {
  state: () => ({ ... }),
  ...
}

const store = new Vuex.Store({
  modules: {
    a: moduleA,
    b: moduleB
  }
})

store.state.a // -> `moduleA`'s state
store.state.b // -> `moduleB`'s state
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The reason it is store.state.a instead of store.a.state is because there is only one state object in Vuex. Under the hood, all of the modules are combined into a single state object.

Vuex docs can provide you with additional information.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!