Skip to content

"dispatch" passed to middlewares only passes through first argument #2501

@Asvarox

Description

@Asvarox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions