question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`createNamespacedHelpers` return mappers that need `this`

See original GitHub issue

Version

3.1.2

Reproduction link

[https://jsfiddle.net/davidmeirlevy/9hbqjmg2/34/)

Steps to reproduce

get a mapper: const { mapActions } = createNamespacedHelpers(MODULE_NAME)

map some action: const {action} = mapActions(['action'])

run this action directly, without adding it to a component methods: action()

What is expected?

the action should be dispacthed

What is actually happening?

This line breaks because we didn’t ran this function from a vue component context: var dispatch = this.$store.dispatch;


when we want to use the mappers from the setup() function of the composition-api, the component’s this shouldn’t be relevant, so you should probably find another way to map actions without expecting being executed as a vue component’s method.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kiakingcommented, Feb 26, 2020

Probably. Not 100% sure just yet, but I guess something like that 👍

1reaction
ktsncommented, Feb 25, 2020

We would not reuse mapXXX helpers for setup usage as they are totally different things and supporting both on one helper function will complicate the implementation. We are working on Vue v3 + Vuex now and considering useXXX composition function for setup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuex: createNamespacedHelpers with dynamic namespace
This style of work around by utilising beforeCreate to access the variables you want should work, I did this from the props passed...
Read more >
How to use Vuex mappers inside Vue Composition API?
I wanted to use the createNamespacedHelpers to get the mappers only once inside my compositions files, so I can export those methods once...
Read more >
Modules | Vuex
If you want your modules to be more self-contained or reusable, you can mark it as namespaced with namespaced: true .
Read more >
Vuex: createNamespacedHelpers with dynamic namespace ...
So I just wanted to let everyone know that brophdawg11 (one of the commenters on the issue #863) created (and open sourced) set...
Read more >
Mapping state from multiple namespaced vuex modules to a ...
Vuex has this helper-function which is supposed to make it easier to work with namespaced vuex modules. store/user.js import { createNamespacedHelpers } from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found