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

action is an object, not a function #34

Closed
fikriauliya opened this issue Nov 26, 2015 · 1 comment
Closed

action is an object, not a function #34

fikriauliya opened this issue Nov 26, 2015 · 1 comment

Comments

@fikriauliya
Copy link

I am not sure whether this is due to the libraries I used, but the following checking in redux-thunk/lib/index.js always yields false:

return typeof action === 'function' ? action(dispatch, getState) : next(action);

It turns out the typeof action == "object.
Here is the output of console.log(action):

Object {type: "PERFORM_ACTION", timestamp: 1448528834619}
action: (dispatch)
timestamp: 1448528834619
type: "PERFORM_ACTION"
__proto__: Object

In my case, the solution is to change the code into:

 return typeof action.action === 'function' ? action.action(dispatch, getState) : next(action);

Here are the libraries I use:

"body-parser": "~1.13.2",
"bootstrap": "^3.3.5",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"extract-text-webpack-plugin": "^0.9.1",
"foundation-sites": "^6.0.3",
"history": "^1.13.1",
"jade": "~1.11.0",
"jquery": "^2.1.4",
"lodash": "^3.10.1",
"morgan": "~1.6.1",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "^4.0.0",
"react-router": "^1.0.0",
"redux": "^3.0.4",
"redux-logger": "^2.0.4",
"redux-router": "^1.0.0-beta4",
"redux-thunk": "^1.0.0",
"serve-favicon": "~2.3.0"

I use node v4.2.2 with latest version of Webpack and Babel

@fikriauliya
Copy link
Author

I confirm it's the problem of redux-router acdlite/redux-router#87
Applying the middleware before reduxReactRouter fixes the problem:

const store = compose(
  applyMiddleware(thunk, loggerMiddleware),
  reduxReactRouter({ createHistory }),
  devTools()
)(createStore)(reducer);

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

1 participant