52

How do you access rootState in getters?

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

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

softcode
  • 4,358
  • 12
  • 41
  • 68

1 Answers1

113

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

const getters = {
  getParams: (state, getters, rootState) => {
    return rootState.route.params
  }
}
Bill Criswell
  • 32,161
  • 7
  • 75
  • 66