vuex state from another module 1

vuex state from another module

let newLocalState = context.rootState.moduleName.stateName;

Here is what the above code is Doing:
1. We’re importing the `mapState` helper from Vuex.
2. We’re creating a computed property called `newLocalState` that uses the `mapState` helper to map the state from the root state to a local state.
3. We’re accessing the state from the root state using the `context.rootState` object.
4. We’re accessing the state from the root state using the `context.rootState.moduleName.stateName` object.

### Mapping Getters

Let’s say we have a getter in our root state called `getterName` and we want to map it to a local getter. Here’s how we would do that:

Similar Posts