[Vuejs]-Is there a thing in Vuex that work the same as mapDispatchToProps in Redux?

0👍

So to update data of parent comp. from child component in Vue we can utilize event bus:

Parent:

<template>
  Hi Blake...
  <child-component @trigger="updateData()"></child-component>
</template>
<script>
  export default {
    mounted() {},
    methods: {
      updateData: function() {
        // this will be triggered from child
      }
    }
  }
</script>

Child ( child-component ):

<template>
  <button @click="$emit('trigger')">Trigger Parent Function</button>
</template>
<script>
  export default {
    mounted() {}
  }
</script>

Now this only triggers parent function but you can also send data with event that will be received by parent. This is just Vue without Vuex. If I’m wrong and you’re not looking for this maybe you want to use Vuex mapActions which can be used to import all Vuex actions you need in your component and use them as this.vuexAction instead of this.$store.dispatch('vuexAction').

I hope I helped. Good luck.

Leave a comment