41
votes

How do you access rootState in getters?

const getters = {
  getParams: rootState => {
    return rootState.route.params
  },
}

The above doesn't work. How is this done?

1
More context is needed. Are you in a module? If you are, then you'd need getParams: (state, getters, rootState) => { ... }.Bill Criswell
All right. I added it.Bill Criswell

1 Answers

85
votes

If this getter is in a module rootState is the third arguments.

const getters = {
  getParams: (state, getters, rootState) => {
    return rootState.route.params
  }
}