Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with map* with Vuex4, Vue3 #1948

Open
engineertdog opened this issue Mar 18, 2021 · 4 comments
Open

Issue with map* with Vuex4, Vue3 #1948

engineertdog opened this issue Mar 18, 2021 · 4 comments

Comments

@engineertdog
Copy link

Version

4.0.0

Reproduction link

https://gitlab.com/engineertdog/vuex-demo-bug

Steps to reproduce

Clone the repo and run. I've included code for the working and non-working portions.

What is expected?

I would expect that the map* methods in Vuex4 can be utilized in a computed method so that the get/set methods properly execute getters/setters from the store.

While I am using Quasar, as noticed in the simplified demo, using the function returned from mapGetters inside a computed property does not work and throws errors. The same goes for mapActions when used in conjunction with the set function of the computed property.

However, the functions returned from map* work just fine when used inside of the html template.

What is actually happening?

When using functions returned from map* functions in Vuex4 inside of computed properties (get or set), errors are thrown. The biggest issues seems to be that $this is undefined, but this happens regardless of whether or not arrow functions are used in the computed property.

@towertop
Copy link

map* helpers is not for composition api in setup(), cause they depend on 'this':

https://github.com/vuejs/vuex/blob/4.0/src/helpers.js#L88

@lukeJEdwards
Copy link

have a look at this issue, #1725

@asasugar
Copy link

https://github.com/asasugar/vuex-composition-maphooks 【modified to vuex helpers】

@mkkeems
Copy link

mkkeems commented Dec 11, 2022

Check out this blog post for using the "vuex-composition-helpers" package:
https://blog.codecourse.com/using-vuex-with-the-vue-composition-api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants