'Why is Vuex ...mapState(`${namespace}`, ["stateName1", "stateName2"]) Not working?

It works when I do it like this

computed: {
  ...mapState("namespace", ["state1", "state2"]),
},

But when I try to get the namespace from props, it says it's undefined. Although it clearly did get the value.

  props: ["namespace"],
  computed: {
    ...mapState(`${this.namespace}`, ["state1", "state2"]),
  },

Undefined Error Screenshot of props value shown in Vue chrome extension

Or maybe I just can't use it like this, I'm not sure.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source