Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
How to pass action from parent to child component using mapActions?

I mapped actions from vuex store in my parent component (Home). My parent component includes child component (Buttons). I would like to pass mapped action (decreaseAction) from parent to child. I just added the name of this action to button (in child component) as @click="decreaseAction". It doesn't work though. Sure, I could use @click="$store.dispatch('decreaseAction')" but I wanted to do it the other way, by passing action from parent. Why the action can't be passed directly from parent to child here?

Home.vue

<template>
  <div class="home">
    The App
  </div> 
  <Buttons />
</template>

<script>
import { mapActions } from 'vuex'; 
import Buttons from '@/components/Buttons.vue';

export default {
  name: 'Home',
  methods: mapActions(['decreaseAction']),
  components: {
    Buttons
  }
}
</script>

Buttons.vue

<template>
  <div class="buttons">
    <button @click="decreaseAction">Decrease</button>
    <!-- <button @click="$store.dispatch('decreaseAction')">Decrease</button>  // using $store.dispatch works fine.. -->
  </div>
</template>

<script>
export default {

}
</script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!