-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Actions mapped to namespaced modules pass unexpected explicit undefined
payload to store.dispatch
#1571
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
Comments
This is happening because of https://github.com/vuejs/vuex/blob/v3.1.1/src/store.js#L360 (explicitly passing - return store.dispatch(type, payload)
+ return payload ? store.dispatch(type, payload) : store.dispatch(type) |
I can work on this issue. Seems preety simple to implement @gitlab-winnie solution. |
Closing due to it might already fixed. See comment #1676 (comment). Please feel free to open another issue if this is something that we should solve. |
Uh oh!
There was an error while loading. Please reload this page.
Version
3.1.1
Reproduction link
https://codepen.io/markrian/pen/vqeGZZ?editors=0010
Steps to reproduce
store.dispatch
depending on whether it's a root-mapped action or a namespace-mapped action ([ "foo" ]
and[ "childModule/foo", undefined ]
respectively - note the extraundefined
argument in the second case; the different action name is of course expected)Note that this only really applies in a testing scenario, where the test spies on
store.dispatch
to ensure the component dispatches the expected actions.What is expected?
store.dispatch
receives exactly the same arguments regardless of whether the actions are namespace-mapped or not.What is actually happening?
store.dispatch
receives a payload argument ofundefined
for namespace-mapped actions.I encountered this when refactoring a store into a namespaced module, and found that my expectations needed to change: that
store.dispatch
received an extraundefined
argument.I'm not sure if this should be considered a bug in Vuex, or in my testing approach of spying on
store.dispatch
🤷♂️The text was updated successfully, but these errors were encountered: