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

middlewareAPI dispatch #2068

Closed
derjoker opened this issue Oct 31, 2016 · 1 comment
Closed

middlewareAPI dispatch #2068

derjoker opened this issue Oct 31, 2016 · 1 comment

Comments

@derjoker
Copy link

https://github.com/reactjs/redux/blob/master/src/applyMiddleware.js#L27

hi, I don't understand here, what's the difference between function (action) => dispatch(action) and function dispatch. They both accept action and return whatever comes from dispatch, right? Can we just write as following? Thanks.

var middlewareAPI = {
  getState: store.getState,
  dispatch: dispatch
}
@timdorr
Copy link
Member

timdorr commented Nov 1, 2016

It's to establish a closure so that when dispatch gets swapped out later on, you're referencing the right function.

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

2 participants