-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
Do you want to request a feature or report a bug? Bug
What is the current behavior?
Right now a "dispatch" function that's passed to middlewares passes through only the first argument.
From applyMiddleware.js:
var middlewareAPI = {
getState: store.getState,
dispatch: (action) => dispatch(action)
}I have a custom middleware that accepts a dispatch call with 2 arguments. This works fine in, say, mapDispatchToProps (from react-redux) as it uses store.dispatch, but in dispatch calls in redux-thunk, the second argument disappears.
What is the expected behavior?
All the arguments are passed to the dispatch:
var middlewareAPI = {
getState: store.getState,
dispatch: (...args) => dispatch(...args)
}There are ways to work around it (you can put all the arguments in an array or object), additional arguments can also be stripped by any middleware in middlewares chain, but still it would make things more consistent.
If it makes sense I can submit a PR.